@steedos-widgets/amis-lib 1.2.8 → 1.2.9-beta.1

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/dist/index.esm.js CHANGED
@@ -2577,11 +2577,11 @@ async function getObjectFieldsFilterFormSchema(ctx) {
2577
2577
  payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
2578
2578
  }
2579
2579
  const selfData = api.body.$self;
2580
- const filterFormSearchableFields = selfData.filterFormSearchableFields;
2581
2580
  const uiSchema = selfData.uiSchema;
2582
2581
  const fields = uiSchema.fields;
2583
- const searchableFields = [];
2584
-
2582
+ const filterFormSearchableFields = (selfData.filterFormSearchableFields || []).filter(function(item){
2583
+ return !!fields[item]
2584
+ });
2585
2585
  const resolveAll = function(values){
2586
2586
  payload.data = {
2587
2587
  "body": values
@@ -2596,21 +2596,7 @@ async function getObjectFieldsFilterFormSchema(ctx) {
2596
2596
  return Promise.all(filterFormSearchableFields.map(function (item) {
2597
2597
  const field = _.clone(fields[item]);
2598
2598
  if (
2599
- field && !_.includes(
2600
- [
2601
- "grid",
2602
- "avatar",
2603
- "image",
2604
- "object",
2605
- "[object]",
2606
- "[Object]",
2607
- "[grid]",
2608
- "[text]",
2609
- "audio",
2610
- "file",
2611
- ],
2612
- field.type
2613
- )
2599
+ field && window.isFieldTypeSearchable(field.type)
2614
2600
  ) {
2615
2601
  delete field.defaultValue;
2616
2602
  delete field.required;
@@ -2969,9 +2955,27 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2969
2955
  "headers": {
2970
2956
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
2971
2957
  },
2972
- "data": null,
2958
+ "data": {
2959
+ "$self": "$$"
2960
+ },
2973
2961
  "requestAdaptor": "",
2974
- "adaptor": ""
2962
+ "adaptor": `
2963
+ if(payload.errors){
2964
+ payload.status = 2;
2965
+ payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
2966
+ }
2967
+ const selfData = api.body.$self;
2968
+ const uiSchema = selfData.uiSchema;
2969
+ const fields = uiSchema.fields;
2970
+ const options = (payload.data?.options || []).filter(function(item){
2971
+ let field = fields[item.value];
2972
+ return !!field && window.isFieldTypeSearchable(field.type)
2973
+ });
2974
+ payload.data = {
2975
+ "options": options
2976
+ };
2977
+ return payload;
2978
+ `
2975
2979
  },
2976
2980
  "options": [],
2977
2981
  "required": true,
@@ -3669,9 +3673,9 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3669
3673
  "icon": "fa fa-search",
3670
3674
  "type": "button",
3671
3675
  "badge": {
3672
- "offsetx": [
3673
- -2,
3674
- 2
3676
+ "offset": [
3677
+ -5,
3678
+ 1
3675
3679
  ],
3676
3680
  "size":8,
3677
3681
  "animation": true,
@@ -6198,6 +6202,29 @@ if(typeof window != 'undefined'){
6198
6202
  window.getFieldSearchable = getFieldSearchable;
6199
6203
  }
6200
6204
 
6205
+
6206
+ function isFieldTypeSearchable(fieldType) {
6207
+ return !_$1.includes(
6208
+ [
6209
+ "grid",
6210
+ "avatar",
6211
+ "image",
6212
+ "object",
6213
+ "[object]",
6214
+ "[Object]",
6215
+ "[grid]",
6216
+ "[text]",
6217
+ "audio",
6218
+ "file",
6219
+ ],
6220
+ fieldType
6221
+ )
6222
+ }
6223
+
6224
+ if (typeof window != 'undefined') {
6225
+ window.isFieldTypeSearchable = isFieldTypeSearchable;
6226
+ }
6227
+
6201
6228
  var index = /*#__PURE__*/Object.freeze({
6202
6229
  __proto__: null,
6203
6230
  OMIT_FIELDS: OMIT_FIELDS,
@@ -6209,6 +6236,7 @@ var index = /*#__PURE__*/Object.freeze({
6209
6236
  getSelectFieldOptions: getSelectFieldOptions,
6210
6237
  convertSFieldToAmisField: convertSFieldToAmisField,
6211
6238
  getFieldSearchable: getFieldSearchable,
6239
+ isFieldTypeSearchable: isFieldTypeSearchable,
6212
6240
  getAmisStaticFieldType: getAmisStaticFieldType
6213
6241
  });
6214
6242