From eb2e5c7149183e77b69c49188072f36367131ded Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Fri, 24 Jan 2020 15:57:15 -0300 Subject: [PATCH] remove the filter type Custom_Numeric #349 --- src/classes/tainacan-creator.php | 1 - .../class-tainacan-custom-numeric.php | 250 ------------------ 2 files changed, 251 deletions(-) delete mode 100644 src/views/admin/components/filter-types/custom-numeric/class-tainacan-custom-numeric.php diff --git a/src/classes/tainacan-creator.php b/src/classes/tainacan-creator.php index efd74f176..75a3837f6 100644 --- a/src/classes/tainacan-creator.php +++ b/src/classes/tainacan-creator.php @@ -147,7 +147,6 @@ $Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance(); //register filter type $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Numeric'); -$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Custom_Numeric'); $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Date'); $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Selectbox'); $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Autocomplete'); diff --git a/src/views/admin/components/filter-types/custom-numeric/class-tainacan-custom-numeric.php b/src/views/admin/components/filter-types/custom-numeric/class-tainacan-custom-numeric.php deleted file mode 100644 index 85ad92ac9..000000000 --- a/src/views/admin/components/filter-types/custom-numeric/class-tainacan-custom-numeric.php +++ /dev/null @@ -1,250 +0,0 @@ -set_name( __('Custom Numeric', 'tainacan') ); - $this->set_supported_types(['float']); - $this->set_component('tainacan-filter-custom-numeric'); - $this->set_script(' - var TainacanExtraFilters = TainacanExtraFilters ? TainacanExtraFilters : {}; - - const TainacanFilterCustomNumeric = { - name: "TainacanFilterCustomNumeric", - props: { - filter: Object, - query: Object, - isRepositoryLevel: Boolean, - isUsingElasticSearch: Boolean, - isLoadingItems: Boolean - }, - data: function() { - return { - collectionId: "", - metadatumId: "", - metadatumType: "", - filterTypeOptions: [], - value: null, - filterTypeOptions: [], - comparator: "=" - } - }, - computed: { - comparatorSymbol: function() { - switch(this.comparator) { - case "=": return "="; - case "!=": return "≠"; - case ">": return ">"; - case ">=": return "≥"; - case "<": return "<"; - case "<=": return "≤"; - default: return ""; - } - } - }, - watch: { - "query.metaquery": function() { - this.updateSelectedValues(); - }, - "query.taxquery": function() { - this.updateSelectedValues(); - } - }, - mounted: function() { console.log(this.filter, this.isRepositoryLevel, this.filterTypeOptions) }, - created: function() { - this.collectionId = this.filter.collection_id ? this.filter.collection_id : this.collectionId; - this.metadatumId = this.filter.metadatum.metadatum_id ? this.filter.metadatum.metadatum_id : this.metadatumId; - this.filterTypeOptions = this.filter.filter_type_options ? this.filter.filter_type_options : this.filterTypeOptions; - this.metadatumType = this.filter.metadatum.metadata_type_object && this.filter.metadatum.metadata_type_object.className ? this.filter.metadatum.metadata_type_object.className : this.metadatumType; - }, - methods: { - updateSelectedValues: function(){ - if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) ) - return false; - - let index = this.query.metaquery.findIndex(function(newMetadatum) { return newMetadatum.key == this.metadatumId } ); - - if ( index >= 0){ - let metadata = this.query.metaquery[ index ]; - - if ( metadata.value && metadata.value.length > 0) - this.value = Array.isArray(metadata.value) ? Number(metadata.value[0]) : Number(metadata.value); - - if ( metadata.compare) - this.comparator = metadata.compare; - - if (this.value != undefined) - this.$emit("sendValuesToTags", { label: this.comparator + " " + this.value, value: this.value }); - - } else { - this.value = null; - } - - }, - emit: function() { - - if ( this.value === null || this.value === "") - return; - - this.$emit("input", { - filter: "numeric", - compare: this.comparator, - metadatum_id: this.metadatumId, - collection_id: this.collectionId, - value: this.value, - type: "NUMERIC" - }); - - this.$emit("sendValuesToTags", { label: this.comparator + " " + this.value, value: this.value }); - - }, - onChangeComparator: function(newComparator) { - this.comparator = newComparator; - this.emit(); - } - }, - template: ` -
- - - - =  {{ $i18n.get("is_equal_to") }} - - - ≠  {{ $i18n.get("is_not_equal_to") }} - - - >  {{ $i18n.get("greater_than") }} - - - ≥  {{ $i18n.get("greater_than_or_equal_to") }} - - - <  {{ $i18n.get("less_than") }} - - - ≤  {{ $i18n.get("less_than_or_equal_to") }} - - - - -
- ` - } - TainacanExtraFilters["tainacan-filter-custom-numeric"] = TainacanFilterCustomNumeric; - '); - $this->set_use_max_options(false); - $this->set_preview_template(' -
-
- -
- '); - } - - /** - * @param $filter - * @return string - * @internal param $metadatum - */ - public function render( $filter ){ - return ''; - } - - - /** - * @param \Tainacan\Entities\Filter $filter - * @return array|bool true if is validate or array if has error - */ - public function validate_options(\Tainacan\Entities\Filter $filter) { - if ( !in_array($filter->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) ) - return true; - - return true; - } -} \ No newline at end of file