Skip to content

Commit

Permalink
chore: remove unused code block (#4131)
Browse files Browse the repository at this point in the history
* chore: remove unused code block

* chore: use composition api
  • Loading branch information
baptou12 authored Dec 21, 2023
1 parent 400ab5f commit 8b618d8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 82 deletions.
58 changes: 19 additions & 39 deletions src/components/ressource/montants.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
</fieldset>
</template>

<script lang="ts">
import { PropType } from "vue"
<script setup lang="ts">
import { computed, PropType } from "vue"
import MonthLabel from "@/components/month-label.vue"
import YesNoQuestion from "@/components/yes-no-question.vue"
Expand All @@ -88,19 +88,32 @@ import InputNumber from "@/components/input-number.vue"
import { useStore } from "@/stores/index.js"
import { ResourceType } from "@lib/types/resources.d.js"
const props = defineProps({
type: { type: Object as PropType<ResourceType>, required: true },
index: Number,
})
const emit = defineEmits(["update"])
const store = useStore()
const singleValue = computed({
get: () => props.type.displayMonthly,
set: (value) => emit("update", "displayMonthly", props.index, value),
})
function getQuestionLabel(ressource, debutAnneeGlissante) {
let verbForms = {
const verbForms = {
pensions_alimentaires_versees_individu: "versé",
default: "reçu",
}
let verb = verbForms[ressource.id] || verbForms.default
const verb = verbForms[ressource.id] || verbForms.default
return `${[
"Le montant",
verb,
"est-il le même <b>tous les mois</b> depuis",
debutAnneeGlissante,
].join(" ")} ?`
].join(" ")} ?`
}
function getLongLabel(individu, ressource) {
Expand All @@ -118,39 +131,6 @@ function getLongLabel(individu, ressource) {
}
const verb = verbs[ressource.id] || verbs.default
return `${[subject, aux, verb, "en"].join(" ")} :`
}
export default {
name: "RessourceMontants",
components: {
InputNumber,
MonthLabel,
YesNoQuestion,
},
props: {
type: { type: Object as PropType<ResourceType>, required: true },
index: Number,
},
emits: ["update"],
setup() {
return {
store: useStore(),
}
},
computed: {
singleValue: {
get() {
return this.type.displayMonthly
},
set(value) {
this.$emit("update", "displayMonthly", this.index, value)
},
},
},
methods: {
getQuestionLabel,
getLongLabel,
},
return `${[subject, aux, verb, "en"].join(" ")} :`
}
</script>
43 changes: 0 additions & 43 deletions src/mixins/ressource-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,48 +62,5 @@ export default {
}
}
},
save(types, single) {
if (!types.length) {
return
} else if (single) {
const updatedRessources = {}
this.types.forEach((t) => {
updatedRessources[t.meta.id] = Object.assign(
{},
t.individu[t.meta.id]
)
t.months.forEach((m) => {
updatedRessources[t.meta.id][m.id] =
t.amounts[m.id] || t.amounts[m.id] === 0
? t.amounts[m.id]
: t.amounts[this.store.dates.thisMonth.id] || 0
})

const extras = t.meta.extra || []
extras.forEach((e) => {
updatedRessources[e.id] = t.extra[e.id]
})
})
} else {
this.types.forEach((t) => {
const updatedRessources = {}
updatedRessources[t.meta.id] = Object.assign(
{},
t.individu[t.meta.id]
)
t.months.forEach((m) => {
updatedRessources[t.meta.id][m.id] =
t.amounts[m.id] || t.amounts[m.id] === 0
? t.amounts[m.id]
: t.amounts[this.store.dates.thisMonth.id] || 0
})

const extras = t.meta.extra || []
extras.forEach((e) => {
updatedRessources[e.id] = t.extra[e.id]
})
})
}
},
},
}

0 comments on commit 8b618d8

Please sign in to comment.