@phoenix-cg/v-filters 0.1.11 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phoenix-cg/v-filters",
3
- "version": "0.1.11",
3
+ "version": "0.1.14",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -126,7 +126,6 @@ export default {
126
126
  },
127
127
  data () {
128
128
  return {
129
- inited: false,
130
129
  filters: {},
131
130
  editedInside: false,
132
131
  editedFields: []
@@ -149,7 +148,7 @@ export default {
149
148
  let filters = {}
150
149
  Object.keys(this.filters).forEach(name => {
151
150
  if (this.editedFields.includes(name)) {
152
- filters[name] = this.filters[name].map(value => value._id || value)
151
+ filters[name] = this.filters[name].map(value => value._id && value._id.toString() || value)
153
152
  }
154
153
  })
155
154
  return filters
@@ -165,7 +164,8 @@ export default {
165
164
 
166
165
  this.fields.forEach(field => {
167
166
  let value = field._type === 'range' ? field.value : []
168
- if (field._type === 'select') {
167
+ const valueNotArray = ['select', 'tab'].includes(field._type)
168
+ if (valueNotArray) {
169
169
  [value] = field.value
170
170
  }
171
171
  if (params[field._name] && !isReset) {
@@ -182,7 +182,7 @@ export default {
182
182
  value = paramsValue
183
183
  }
184
184
  this.addEditedField(field._name)
185
- } else if ((!params[field._name] || isReset) && field._type === 'select') {
185
+ } else if ((!params[field._name] || isReset) && valueNotArray) {
186
186
  [value] = field.value
187
187
  } else if (!params[field._name] || isReset) {
188
188
  value = field.value
@@ -195,6 +195,9 @@ export default {
195
195
  .some(checkedValue => !checkedValue)
196
196
  break
197
197
  case 'select':
198
+ case 'tab':
199
+ fieldIsEdited = field.value.length > 0 && field.value[0]._id !== field.data[0]._id
200
+ break
198
201
  case 'checkbox':
199
202
  fieldIsEdited = field.value.length > 0
200
203
  break
@@ -219,29 +222,7 @@ export default {
219
222
  }
220
223
  },
221
224
  doAction () {
222
- if (this.immediate) {
223
- this.showResult()
224
- } else {
225
- this.requestCount()
226
- if (!this.inited && !this.hideResult) {
227
- this.showResult()
228
- }
229
- this.inited = true
230
- }
231
- },
232
- isFieldsEqual (arr1, arr2) {
233
- let equal = true
234
- arr1.forEach(item => {
235
- let arr2Item = arr2.find(arr2Item => {
236
- let val = item._id || item
237
- let val2 = arr2Item._id || arr2Item
238
- return val === val2
239
- })
240
- if (!arr2Item) {
241
- equal = false
242
- }
243
- })
244
- return equal
225
+ this.immediate ? this.showResult() : this.requestCount()
245
226
  },
246
227
  requestCount () {
247
228
  this.$emit('request-count', this.flatFilters)