Feat: Tag filtering not on words
This commit is contained in:
		| @@ -1,10 +1,5 @@ | ||||
| --- | ||||
| postes: | ||||
|   total: | ||||
|     name: Tout | ||||
|     variant: info | ||||
|     icon: file-invoice-dollar | ||||
|  | ||||
|   cash: | ||||
|     name: Cash | ||||
|     variant: info | ||||
|   | ||||
| @@ -25,6 +25,11 @@ export default { | ||||
|   ], | ||||
|   data () { | ||||
|     return { | ||||
|       default_poste: { | ||||
|         name: 'Tout', | ||||
|         variant: 'info', | ||||
|         icon: 'file-invoice-dollar' | ||||
|       } | ||||
|     } | ||||
|   }, | ||||
|   computed: { | ||||
| @@ -32,15 +37,23 @@ export default { | ||||
|       'postes' | ||||
|     ]), | ||||
|     ...mapGetters('datas', [ | ||||
|       'libelle_filter_rows' | ||||
|       'tag_filter_rows' | ||||
|     ]), | ||||
|     poste () { | ||||
|       return this.postes[this.postename] | ||||
|       if (this.postename) { | ||||
|         return this.postes[this.postename] | ||||
|       } else { | ||||
|         return this.default_poste | ||||
|       } | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     filter_rows () { | ||||
|       return this.libelle_filter_rows(this.poste.words, this.poste.invert) | ||||
|       if (this.poste === this.default_poste) { | ||||
|         return this.tag_filter_rows([]) | ||||
|       } else { | ||||
|         return this.tag_filter_rows([this.poste.name]) | ||||
|       } | ||||
|     }, | ||||
|     total () { | ||||
|       return Math.round( | ||||
|   | ||||
| @@ -43,6 +43,18 @@ export default { | ||||
|         return (new Date(x.Date) >= start) & (new Date(x.Date) < end) | ||||
|       }) | ||||
|     }, | ||||
|     tag_filter_rows: (state, getters) => (tags) => { | ||||
|       if (tags) { | ||||
|         return getters.date_filter_rows.filter(row => { | ||||
|           return tags.every(t => { | ||||
|             return row.tags.map(t => t.name.toLowerCase()) | ||||
|               .indexOf(t.toLowerCase()) > -1 | ||||
|           }) | ||||
|         }) | ||||
|       } else { | ||||
|         return getters.date_filter_rows | ||||
|       } | ||||
|     }, | ||||
|     libelle_filter_rows: (state, getters) => (words, invert) => { | ||||
|       if (!words) { | ||||
|         return getters.date_filter_rows | ||||
|   | ||||
| @@ -15,15 +15,19 @@ | ||||
|     </b-container> | ||||
|  | ||||
|      <b-card-group deck class="mb-3"> | ||||
|        <box @click.native="set_poste('total')" postename="total"></box> | ||||
|        <box @click.native="set_poste('cash')" postename="cash"></box> | ||||
|        <box @click.native="set_poste('CB')" postename="CB"></box> | ||||
|        <box @click.native="set_poste('other')" postename="other"></box> | ||||
|        <box @click.native="set_postes_filter([])"></box> | ||||
|        <box @click.native="set_postes_filter(['cash'])" postename="cash"></box> | ||||
|        <box @click.native="set_postes_filter(['CB'])" postename="CB"></box> | ||||
|        <box @click.native="set_postes_filter(['other'])" postename="other"></box> | ||||
|      </b-card-group> | ||||
|  | ||||
| <<<<<<< HEAD | ||||
|      <postes-comparison></postes-comparison> | ||||
|  | ||||
|     <b-table striped hover :items="filtered_rows(poste.words, poste.invert)" :fields='fields'> | ||||
| ======= | ||||
|     <b-table striped hover :items="filtered_rows" :fields='fields'> | ||||
| >>>>>>> Feat: Tag filtering not on words | ||||
|       <template slot="tags" slot-scope="data"> | ||||
|         <div v-for="tag in data.item.tags"> | ||||
|           <div v-if="tag.name !== 'Tout'"> | ||||
| @@ -65,10 +69,14 @@ export default { | ||||
|         }, | ||||
|         { | ||||
|           key: 'tags', | ||||
|           sortable: true | ||||
|         } | ||||
|       ], | ||||
|       poste: {} | ||||
|       default_poste: { | ||||
|         name: 'Tout', | ||||
|         variant: 'info', | ||||
|         icon: 'file-invoice-dollar' | ||||
|       }, | ||||
|       postes_filter: [] | ||||
|     } | ||||
|   }, | ||||
|   mounted: function () { | ||||
| @@ -78,11 +86,15 @@ export default { | ||||
|   computed: { | ||||
|     ...mapGetters({ | ||||
|       'csvs': 'datas/csvs', | ||||
|       'filtered_rows': 'datas/libelle_filter_rows', | ||||
|       'tag_filter_rows': 'datas/tag_filter_rows', | ||||
|       'start': 'datas/start', | ||||
|       'end': 'datas/end', | ||||
|       'postes': 'config/postes' | ||||
|     }) | ||||
|     }), | ||||
|     filtered_rows () { | ||||
|       return this.tag_filter_rows(this.postes_filter) | ||||
|     } | ||||
|  | ||||
|   }, | ||||
|   methods: { | ||||
|     ...mapActions('datas', [ | ||||
| @@ -94,8 +106,8 @@ export default { | ||||
|     table_date_format (date) { | ||||
|       return date | ||||
|     }, | ||||
|     set_poste (postename) { | ||||
|       this.poste = this.postes[postename] | ||||
|     set_postes_filter (postenames) { | ||||
|       this.postes_filter = postenames | ||||
|     } | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user