@steedos-widgets/amis-lib 6.3.0-beta.17 → 6.3.0-beta.18

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
@@ -5793,21 +5793,16 @@ const getDropdown = (dropdownButtons)=>{
5793
5793
  "hideCaret": true,
5794
5794
  "className": "mr-0 steedos-mobile-header-drop-down",
5795
5795
  "closeOnClick": true,
5796
- "menuClassName": "buttons-drawer fixed inset-0 bg-none border-0 shadow-none",
5796
+ "menuClassName": "buttons-drawer fixed bg-none border-0 shadow-none",
5797
5797
  "align": "right",
5798
5798
  "body": [
5799
5799
  {
5800
5800
  "type": "action",
5801
5801
  "style": {
5802
- "position": "fixed",
5803
- "top": 0,
5804
- "right": 0,
5805
- "bottom": 0,
5806
- "left": 0,
5807
5802
  "z-index": 1,
5808
5803
  "background": "var(--Drawer-overlay-bg)",
5809
- "height": "unset",
5810
- "width": "unset",
5804
+ "height": "100%",
5805
+ "width": "100%",
5811
5806
  "padding": "0",
5812
5807
  "margin": "0",
5813
5808
  "border-radius": "0"
@@ -6601,6 +6596,217 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6601
6596
  };
6602
6597
  }
6603
6598
 
6599
+ const getNewListviewButtonSchema = ()=>{
6600
+ return {
6601
+ "type": "button",
6602
+ "label": i18next.t('frontend_listview_control_new_label'),
6603
+ "className": "steedos-listview-new-button",
6604
+ "onEvent": {
6605
+ "click": {
6606
+ "weight": 0,
6607
+ "actions": [
6608
+ {
6609
+ "dialog": {
6610
+ "type": "dialog",
6611
+ "title": i18next.t('frontend_listview_control_new_title'),
6612
+ "data": {
6613
+ //"&":"$$",2.7、2.9、3.0在此处失效
6614
+ "all": "${uiSchema.list_views.all}",
6615
+ "list_view": "${uiSchema.list_views[listName]}",
6616
+ "appId": "${appId}",
6617
+ "global": "${global}",
6618
+ "targetObjectName": "${objectName}",
6619
+ "context": "${context}"
6620
+ },
6621
+ "body": [
6622
+ {
6623
+ "type": "steedos-object-form",
6624
+ "label": "对象表单",
6625
+ "objectApiName": "object_listviews",
6626
+ "recordId": "",
6627
+ "mode": "edit",
6628
+ "layout": "normal",
6629
+ "defaultData": {
6630
+ "&": "${list_view}",
6631
+ "name":"",
6632
+ "label":"",
6633
+ "filters":"",
6634
+ "shared":false,
6635
+ "object_name": "${targetObjectName}",
6636
+ "_id":"",
6637
+ "shared_to": null,
6638
+ "shared_to_organizations": null,
6639
+ "locked": false,
6640
+ "owner": null,
6641
+ "company_id": null,
6642
+ "company_ids": null,
6643
+ "is_system": false
6644
+ },
6645
+ "fieldsExtend": fieldsExtend$5(),
6646
+ "fields": fields$1(),
6647
+ "onEvent": {
6648
+ "submitSucc": {
6649
+ "weight": 0,
6650
+ "actions": [
6651
+ {
6652
+ "args": {
6653
+ // 直接使用recordId不能拿到数据,只能通过result里面拿数据
6654
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
6655
+ "blank": false
6656
+ },
6657
+ "actionType": "url",
6658
+ }
6659
+ ]
6660
+ }
6661
+ },
6662
+ "messages": {
6663
+ "success": i18next.t('frontend_listview_control_new_message_success'),
6664
+ "failed": i18next.t('frontend_listview_control_new_message_failed')
6665
+ },
6666
+ }
6667
+ ],
6668
+ "showCloseButton": true,
6669
+ "showErrorMsg": true,
6670
+ "showLoading": true,
6671
+ "closeOnEsc": false,
6672
+ "dataMapSwitch": false,
6673
+ "size": "lg"
6674
+ },
6675
+ "actionType": "dialog"
6676
+ }
6677
+ ]
6678
+ }
6679
+ }
6680
+ }
6681
+ };
6682
+
6683
+ function fields$1(){
6684
+ return [
6685
+ "label",
6686
+ "name",
6687
+ "object_name",
6688
+ "filter_scope",
6689
+ "show_count",
6690
+ "columns",
6691
+ "sort",
6692
+ "filters",
6693
+ "mobile_columns",
6694
+ "searchable_fields",
6695
+ "is_system",
6696
+ "shared",
6697
+ "shared_to",
6698
+ "shared_to_organizations"
6699
+ ]
6700
+ }
6701
+
6702
+ function fieldsExtend$5(){
6703
+ return {
6704
+ "group": "",
6705
+ "label": {
6706
+ "group": "",
6707
+ "is_wide": true
6708
+ },
6709
+ "name": {
6710
+ "group": "",
6711
+ "amis": {
6712
+ "hidden": true,
6713
+ "required": false
6714
+ }
6715
+ },
6716
+ "object_name": {
6717
+ "group": "",
6718
+ "amis": {
6719
+ "hidden": true
6720
+ }
6721
+ },
6722
+ "filter_scope": {
6723
+ "group": "",
6724
+ "amis": {
6725
+ "hidden": true,
6726
+ "required": false
6727
+ }
6728
+ },
6729
+ "columns": {
6730
+ "group": "",
6731
+ "amis": {
6732
+ "hidden": true,
6733
+ "required": false
6734
+ }
6735
+ },
6736
+ "mobile_columns":{
6737
+ "group": "",
6738
+ "amis": {
6739
+ "hidden": true,
6740
+ "required": false
6741
+ }
6742
+ },
6743
+ "searchable_fields":{
6744
+ "group": "",
6745
+ "amis": {
6746
+ "hidden": true,
6747
+ "required": false
6748
+ }
6749
+ },
6750
+ "filter_fields": {
6751
+ "group": "",
6752
+ "amis": {
6753
+ "hidden": true,
6754
+ "required": false
6755
+ }
6756
+ },
6757
+ "scrolling_mode": {
6758
+ "group": "",
6759
+ "amis": {
6760
+ "hidden": true,
6761
+ "required": false
6762
+ }
6763
+ },
6764
+ "sort": {
6765
+ "group": "",
6766
+ "amis": {
6767
+ "hidden": true,
6768
+ "required": false
6769
+ }
6770
+ },
6771
+ "show_count": {
6772
+ "group": "",
6773
+ "amis": {
6774
+ "hidden": true,
6775
+ "required": false
6776
+ }
6777
+ },
6778
+ "type": {
6779
+ "group": "",
6780
+ "amis": {
6781
+ "hidden": true,
6782
+ "required": false
6783
+ }
6784
+ },
6785
+ "shared": {
6786
+ "group": "",
6787
+ "amis": {
6788
+ "visibleOn": "${false}"
6789
+ }
6790
+ },
6791
+ "shared_to": {
6792
+ "group": "",
6793
+ "amis":{
6794
+ "type": "radios",
6795
+ "inline": false
6796
+ }
6797
+ },
6798
+ "shared_to_organizations": {
6799
+ "group": ""
6800
+ },
6801
+ "filters": {
6802
+ "group": "",
6803
+ "amis": {
6804
+ "hidden": true
6805
+ }
6806
+ }
6807
+ }
6808
+ }
6809
+
6604
6810
  /**
6605
6811
  * 列表视图顶部第一行amisSchema
6606
6812
  * @param {*} objectSchema 对象UISchema
@@ -6610,38 +6816,504 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
6610
6816
  const { icon, label } = objectSchema;
6611
6817
  const disabled_list_views = objectSchema.permissions.disabled_list_views;
6612
6818
  const listViewButtonOptions = [];
6613
- each(
6614
- objectSchema.list_views,
6615
- (listView, name) => {
6616
- if(name === "lookup" || (disabled_list_views && disabled_list_views.indexOf(listView._id)>-1)){
6617
- // 内置lookup为弹出选择专用视图,根据用户权限被禁用的视图,不显示在列表切换区域
6618
- return;
6819
+ const initApiAdaptor = `
6820
+ var data;
6821
+ if (recordId) {
6822
+ data = payload.data || { _filters_type_controller: 'conditions' };
6823
+ //数据格式转换
6824
+ if (data) {
6825
+ data.sort = lodash.map(data.sort, (item) => {
6826
+ return item.field_name + ":" + item.order;
6827
+ });
6828
+ data.searchable_fields = lodash.map(data.searchable_fields, 'field');
6829
+
6830
+ if (data.filters && lodash.isString(data.filters)) {
6831
+ try {
6832
+ data.filters = JSON.parse(data.filters);
6833
+ } catch (e) { }
6834
+ }
6835
+
6836
+ if (data.filters && lodash.isString(data.filters)) {
6837
+ data._filters_type_controller = 'function';
6838
+ } else {
6839
+ data._filters_type_controller = 'conditions'
6840
+ }
6841
+
6842
+ if (data._filters_type_controller === 'conditions') {
6843
+ data._filters_conditions = window.amisConvert.filtersToConditions(data.filters || []);
6844
+ } else {
6845
+ data._filters_function = data.filters;
6846
+ }
6619
6847
  }
6620
- listViewButtonOptions.push({
6621
- type: "button",
6622
- label: listView.label,
6623
- actionType: "link",
6624
- link: `/app/\${appId}/${objectSchema.name}/grid/${name}`
6848
+ } else {
6849
+ const uiSchema = api.body.uiSchema;
6850
+ const contextDefaultData = context && context.data && context.data.defaultData; const defaultData = api.body.defaultData || contextDefaultData;
6851
+ let defaultValues = {};
6852
+ _.each(uiSchema && uiSchema.fields, function (field) {
6853
+ var value = SteedosUI.getFieldDefaultValue(field, api.body.global);
6854
+ if (!_.isNil(value)) {
6855
+ defaultValues[field.name] = value;
6856
+ }
6625
6857
  });
6858
+ if (defaultData && _.isObject(defaultData) && !_.isArray(defaultData)) {
6859
+ data = Object.assign({}, defaultValues, defaultData);
6860
+ }else{data = Object.assign({}, defaultValues) }
6626
6861
  }
6627
- );
6628
-
6629
- let amisButtonsSchema = getObjectListViewButtonsSchemas(objectSchema, {formFactor: ctx.formFactor});
6630
- const reg = new RegExp('_', 'g');
6631
- const standardIcon = icon && icon.replace(reg, '-');
6632
- const standardNewButton = _.find(amisButtonsSchema, { name: "standard_new" });
6633
- const buttonSchema = [{
6634
- "type": "flex",
6635
- "items": amisButtonsSchema,
6636
- "visibleOn": "${display == 'split'?false:true}"
6637
- }];
6638
- if(ctx.formFactor !== 'SMALL'){
6639
- const restButtons = Array.isArray(amisButtonsSchema) ? amisButtonsSchema.filter(obj => obj.name !== "standard_new"):[];
6640
- buttonSchema.push({
6641
- "type": "flex",
6642
- "items":[
6643
- standardNewButton,
6644
- (restButtons.length > 0) && {
6862
+ for (key in data) {
6863
+ if (data[key] === null) {
6864
+ delete data[key];
6865
+ }
6866
+ }
6867
+ payload.data = data;
6868
+ delete payload.extensions; if (data.is_enable != false) { data.is_enable = true; };
6869
+ return payload;
6870
+ `;
6871
+ const apiRequestAdaptor = `
6872
+ delete formData.created;
6873
+ delete formData.created_by;
6874
+ delete formData.modified;
6875
+ delete formData.modified_by;
6876
+ delete formData._display;
6877
+
6878
+ //数据格式转换
6879
+ formData.sort = lodash.map(formData.sort, (item) => {
6880
+ const arr = item.split(':');
6881
+ return { field_name: arr[0], order: arr[1] };
6882
+ });
6883
+
6884
+ formData.searchable_fields = lodash.map(formData.searchable_fields, (item) => {
6885
+ return { field: item };
6886
+ });
6887
+
6888
+ if (!formData._filters_type_controller) {
6889
+ formData._filters_type_controller = 'conditions';
6890
+ }
6891
+
6892
+ if (formData._filters_type_controller === 'conditions' && formData._filters_conditions) {
6893
+ formData.filters = window.amisConvert.conditionsToFilters(formData._filters_conditions);
6894
+ // formData.filters = JSON.stringify(window.amisConvert.conditionsToFilters(formData._filters_conditions), null, 4);
6895
+ } else {
6896
+ formData.filters = formData._filters_function || null;
6897
+ }
6898
+
6899
+ delete formData._filters_type_controller;
6900
+ delete formData._filters_conditions;
6901
+ delete formData._filters_function;
6902
+
6903
+ query = \`mutation{record: object_listviews__insert(doc: {__saveData}){_id}}\`;
6904
+ if (formData.recordId) {
6905
+ query = \`mutation{record: object_listviews__update(id: "\` + formData._id + \`", doc: {__saveData}){_id}}\`;
6906
+ };
6907
+ __saveData = JSON.stringify(JSON.stringify(formData));
6908
+
6909
+ api.data = { query: query.replace('{__saveData}', __saveData) };
6910
+ return api;
6911
+ `;
6912
+ each(
6913
+ objectSchema.list_views,
6914
+ (listView, name) => {
6915
+ if(name === "lookup" || (disabled_list_views && disabled_list_views.indexOf(listView._id)>-1)){
6916
+ // 内置lookup为弹出选择专用视图,根据用户权限被禁用的视图,不显示在列表切换区域
6917
+ return;
6918
+ }
6919
+ listViewButtonOptions.push({
6920
+ type: "button",
6921
+ label: listView.label,
6922
+ body: [
6923
+ {
6924
+ "type": "flex",
6925
+ "alignItems": "center",
6926
+ "justify": "space-between",
6927
+ "items": [
6928
+ {
6929
+ "type": "tpl",
6930
+ "tpl": listView.label
6931
+ },
6932
+ {
6933
+ "type": "button",
6934
+ "className": "steedos-listview-edit-button",
6935
+ "icon": "fa fa-edit",
6936
+ "actionType": "dialog",
6937
+ "hiddenOn": `!((global.user.is_space_admin || global.userId == '${listView.owner || ""}') && !!'${listView.owner || ""}')`,
6938
+ "dialog": {
6939
+ "type": "dialog",
6940
+ "title": "编辑 列表视图",
6941
+ "data": {
6942
+ "object_name": "${objectName}",
6943
+ "recordId": listView._id,
6944
+ "listName": "${listName}",
6945
+ "appId": "${appId}",
6946
+ "context": "${context}",
6947
+ "global": "${global}",
6948
+ "_id": listView._id
6949
+ },
6950
+ "body": [
6951
+ {
6952
+ "type": "steedos-object-form",
6953
+ "label": "对象表单",
6954
+ "objectApiName": "object_listviews",
6955
+ "recordId": "${recordId}",
6956
+ "className": "sm:rounded sm:border-gray-300 bg-white",
6957
+ "layout": "horizontal",
6958
+ "form": {
6959
+ "id": "form_object_listviews"
6960
+ },
6961
+ "mode": "edit",
6962
+ "enableTabs": true,
6963
+ "fields": [
6964
+ "label",
6965
+ "sort_no",
6966
+ "crud_mode",
6967
+ "shared",
6968
+ "shared_to",
6969
+ 'shared_to_organizations',
6970
+ "columns",
6971
+ "columns.$",
6972
+ "columns.$.field",
6973
+ "columns.$.width",
6974
+ "columns.$.wrap",
6975
+ "mobile_columns",
6976
+ "mobile_columns.$",
6977
+ "mobile_columns.$.field",
6978
+ "sort",
6979
+ "sort.$",
6980
+ "sort.$.field_name",
6981
+ "sort.$.order",
6982
+ "filters",
6983
+ "searchable_fields",
6984
+ "searchable_fields.$",
6985
+ "searchable_fields.$.field",
6986
+ ],
6987
+ "tabsMode": "line",
6988
+ "fieldsExtend": {
6989
+ "columns": {
6990
+ "amis": {
6991
+ "showIndex": true,
6992
+ "footerToolbar": [
6993
+ {
6994
+ "type": "button",
6995
+ "label": "${'object_listviews.listview_form.field_set' | t}",
6996
+ "actionType": "dialog",
6997
+ "dialog": {
6998
+ "type": "dialog",
6999
+ "title": "${'object_listviews.listview_form.displayed_columns' | t}",
7000
+ "size": "md",
7001
+ "body": [
7002
+ {
7003
+ "type": "transfer",
7004
+ "options": [
7005
+ ],
7006
+ "multiple": true,
7007
+ "id": "u:92c0b3cccca0",
7008
+ "required": true,
7009
+ "placeholder": "-",
7010
+ "className": "col-span-2 m-0",
7011
+ "checkAll": false,
7012
+ "searchable": true,
7013
+ "sortable": true,
7014
+ "itemHeight": 40,
7015
+ "source": {
7016
+ "method": "get",
7017
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
7018
+ "headers": {
7019
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
7020
+ },
7021
+ "requestAdaptor": "",
7022
+ "adaptor": ""
7023
+ },
7024
+ "joinValues": false,
7025
+ "extractValue": true,
7026
+ "name": "columns_quick_select",
7027
+ "value": "${columns|pick:field|split}"
7028
+ }
7029
+ ],
7030
+ "onEvent": {
7031
+ "confirm": {
7032
+ "actions": [
7033
+ {
7034
+ "actionType": "custom",
7035
+ "script": "const columns = [];\nconst columns_quick_select = _.cloneDeep(event.data.columns_quick_select);\n_.forEach(columns_quick_select, function (field) {\n const column_field = _.find(event.data.columns, { field });\n if (column_field) {\n columns.push(column_field)\n } else {\n columns.push({\n field\n })\n }\n});\ndoAction({\n \"componentId\": \"form_object_listviews\",\n \"actionType\": \"setValue\",\n \"args\": {\n \"value\": {\n columns\n }\n }\n});"
7036
+ }
7037
+ ]
7038
+ }
7039
+ }
7040
+ }
7041
+ }
7042
+ ],
7043
+ "addable": false,
7044
+ "draggable": false,
7045
+ "columns": [
7046
+ {
7047
+ "name": "field",
7048
+ "inlineEditMode": false
7049
+ },
7050
+ {
7051
+ "name": "width",
7052
+ "width": 100
7053
+ },
7054
+ {
7055
+ "name": "wrap",
7056
+ "width": 50
7057
+ }
7058
+ ],
7059
+ "enableDialog": false
7060
+ }
7061
+ },
7062
+ "sort": {
7063
+ "label": "",
7064
+ "amis": {
7065
+ "type": "tabs-transfer",
7066
+ "options": [
7067
+ ],
7068
+ "id": "u:32f3e4e73115",
7069
+ "strictMode": true,
7070
+ "itemHeight": 40,
7071
+ "source": {
7072
+ "method": "get",
7073
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/sortFields/options",
7074
+ "headers": {
7075
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
7076
+ },
7077
+ "data": null,
7078
+ "requestAdaptor": "",
7079
+ "adaptor": "",
7080
+ "sendOn": "!!this.object_name"
7081
+ },
7082
+ "visibleOn": "!!this.object_name",
7083
+ "sortable": true,
7084
+ "className": "col-span-2 m-0",
7085
+ "searchable": true,
7086
+ "checkAll": false,
7087
+ "clearValueOnHidden": false,
7088
+ "joinValues": false,
7089
+ "extractValue": true,
7090
+ "en-US": {
7091
+ "label": "Default Sort Order"
7092
+ },
7093
+ "multiple": true
7094
+ }
7095
+ },
7096
+ "filters": {
7097
+ "label": "",
7098
+ "amis": {
7099
+ "type": "group",
7100
+ "body": [
7101
+ {
7102
+ "type": "radios",
7103
+ "label": "${'object_listviews.listview_form.filter_configuration_method' | t}",
7104
+ "name": "_filters_type_controller",
7105
+ "options": [
7106
+ {
7107
+ "label": "${'object_listviews.listview_form.conditions_combination' | t}",
7108
+ "value": "conditions"
7109
+ },
7110
+ {
7111
+ "label": "${'object_listviews.listview_form.javascript' | t}",
7112
+ "value": "function"
7113
+ }
7114
+ ],
7115
+ "id": "u:318671bc196c",
7116
+ "joinValues": true,
7117
+ "className": "col-span-2 m-0",
7118
+ "language": "javascript",
7119
+ "visibleOn": "false",
7120
+ "en-US": {
7121
+ "label": "Controller"
7122
+ }
7123
+ },
7124
+ {
7125
+ "type": "condition-builder",
7126
+ "label": "",
7127
+ "labelClassName": "none",
7128
+ "name": "_filters_conditions",
7129
+ "description": "",
7130
+ "id": "u:a9f2232e30d7",
7131
+ "source": {
7132
+ "method": "get",
7133
+ "url": "${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${object_name}",
7134
+ "dataType": "json",
7135
+ "headers": {
7136
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
7137
+ }
7138
+ },
7139
+ "disabled": false,
7140
+ "className": "col-span-2 m-0",
7141
+ "visibleOn": "!!this.object_name",
7142
+ "en-US": {
7143
+ "label": "Filters Conditions"
7144
+ }
7145
+ },
7146
+ {
7147
+ "type": "editor",
7148
+ "label": "${'object_listviews.listview_form.javascript' | t}",
7149
+ "name": "_filters_function",
7150
+ "id": "u:84714ec9abba",
7151
+ "visibleOn": "!!this.object_name && !!this._filters_type_controller && _filters_type_controller== 'function'",
7152
+ "className": "col-span-2 m-0",
7153
+ "labelClassName": "hidden"
7154
+ }
7155
+ ]
7156
+ }
7157
+ },
7158
+ "mobile_columns": {
7159
+ "amis": {
7160
+ "showIndex": true,
7161
+ "footerToolbar": [
7162
+ {
7163
+ "type": "button",
7164
+ "label": "${'object_listviews.listview_form.field_set' | t}",
7165
+ "actionType": "dialog",
7166
+ "dialog": {
7167
+ "type": "dialog",
7168
+ "title": "${'object_listviews.listview_form.displayed_columns' | t}",
7169
+ "size": "md",
7170
+ "body": [
7171
+ {
7172
+ "type": "transfer",
7173
+ "options": [
7174
+ ],
7175
+ "multiple": true,
7176
+ "id": "u:92c0b3cccca0",
7177
+ "required": true,
7178
+ "placeholder": "-",
7179
+ "className": "col-span-2 m-0",
7180
+ "itemHeight": 40,
7181
+ "checkAll": false,
7182
+ "searchable": true,
7183
+ "sortable": true,
7184
+ "source": {
7185
+ "method": "get",
7186
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
7187
+ "headers": {
7188
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
7189
+ },
7190
+ "requestAdaptor": "",
7191
+ "adaptor": ""
7192
+ },
7193
+ "joinValues": false,
7194
+ "extractValue": true,
7195
+ "name": "columns_quick_select",
7196
+ "value": "${mobile_columns|pick:field|split}"
7197
+ }
7198
+ ],
7199
+ "onEvent": {
7200
+ "confirm": {
7201
+ "actions": [
7202
+ {
7203
+ "actionType": "custom",
7204
+ "script": "const mobile_columns = [];\nconst columns_quick_select = _.cloneDeep(event.data.columns_quick_select);\n_.forEach(columns_quick_select, function (field) {\n const column_field = _.find(event.data.mobile_columns, { field });\n if (column_field) {\n mobile_columns.push(column_field)\n } else {\n mobile_columns.push({\n field\n })\n }\n});\ndoAction({\n \"componentId\": \"form_object_listviews\",\n \"actionType\": \"setValue\",\n \"args\": {\n \"value\": {\n mobile_columns\n }\n }\n});"
7205
+ }
7206
+ ]
7207
+ }
7208
+ }
7209
+ }
7210
+ }
7211
+ ],
7212
+ "columns": [
7213
+ {
7214
+ "name": "field",
7215
+ "inlineEditMode": false
7216
+ }
7217
+ ],
7218
+ "addable": false,
7219
+ "draggable": false,
7220
+ "enableDialog": false
7221
+ }
7222
+ },
7223
+ "searchable_fields": {
7224
+ "label": "",
7225
+ "amis": {
7226
+ "type": "transfer",
7227
+ "options": [
7228
+ ],
7229
+ "selectMode": "list",
7230
+ "searchable": true,
7231
+ "searchApi": "",
7232
+ "sortable": true,
7233
+ "mode": "normal",
7234
+ "searchResultMode": "list",
7235
+ "joinValues": false,
7236
+ "extractValue": true,
7237
+ "itemHeight": 40,
7238
+ "source": {
7239
+ "method": "get",
7240
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
7241
+ "headers": {
7242
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
7243
+ },
7244
+ "data": null,
7245
+ "requestAdaptor": "",
7246
+ "adaptor": "",
7247
+ "sendOn": "!!this.object_name"
7248
+ },
7249
+ "visibleOn": "!!this.object_name",
7250
+ "className": "col-span-2 m-0",
7251
+ "multiple": true,
7252
+ "id": "u:adb91066539e"
7253
+ }
7254
+ },
7255
+ "shared_to": {
7256
+ "amis":{
7257
+ "type": "radios",
7258
+ "inline": false
7259
+ },
7260
+ "group": "",
7261
+ "is_wide": true
7262
+ }
7263
+ },
7264
+ initApiAdaptor,
7265
+ apiRequestAdaptor,
7266
+ "onEvent": {
7267
+ "submitSucc": {
7268
+ "weight": 0,
7269
+ "actions": [
7270
+ {
7271
+ "args": {
7272
+ "url": "${context.rootUrl}/app/${appId}/${object_name}/grid/${name}",
7273
+ "blank": false
7274
+ },
7275
+ "actionType": "url",
7276
+ },
7277
+ ]
7278
+ }
7279
+ },
7280
+ "id": "u:ce9e3fcc411a"
7281
+ }
7282
+ ],
7283
+ "className": "steedos-overflow-visible-dialog",
7284
+ "showCloseButton": true,
7285
+ "showErrorMsg": true,
7286
+ "showLoading": true,
7287
+ "closeOnEsc": false,
7288
+ "dataMapSwitch": false,
7289
+ "size": "lg"
7290
+ }
7291
+ }
7292
+ ]
7293
+ }
7294
+ ],
7295
+ actionType: "link",
7296
+ link: `/app/\${appId}/${objectSchema.name}/grid/${name}`
7297
+ });
7298
+ }
7299
+ );
7300
+
7301
+ let amisButtonsSchema = getObjectListViewButtonsSchemas(objectSchema, {formFactor: ctx.formFactor});
7302
+ const reg = new RegExp('_', 'g');
7303
+ const standardIcon = icon && icon.replace(reg, '-');
7304
+ const standardNewButton = _.find(amisButtonsSchema, { name: "standard_new" });
7305
+ const buttonSchema = [{
7306
+ "type": "flex",
7307
+ "items": amisButtonsSchema,
7308
+ "visibleOn": "${display == 'split'?false:true}"
7309
+ }];
7310
+ if(ctx.formFactor !== 'SMALL'){
7311
+ const restButtons = Array.isArray(amisButtonsSchema) ? amisButtonsSchema.filter(obj => obj.name !== "standard_new"):[];
7312
+ buttonSchema.push({
7313
+ "type": "flex",
7314
+ "items":[
7315
+ standardNewButton,
7316
+ (restButtons.length > 0) && {
6645
7317
  "type": "dropdown-button",
6646
7318
  "buttons": restButtons,
6647
7319
  "className": " ml-1",
@@ -6653,6 +7325,8 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
6653
7325
  "visibleOn": "${display == 'split'?true:false}"
6654
7326
  });
6655
7327
  }
7328
+ const listviewNewButton = getNewListviewButtonSchema();
7329
+ listviewNewButton.visibleOn = "global.user.is_space_admin";
6656
7330
  return {
6657
7331
  "type": "grid",
6658
7332
  "columns": [
@@ -6683,14 +7357,17 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
6683
7357
  },
6684
7358
  {
6685
7359
  "type": "dropdown-button",
6686
- "className": "",
7360
+ "className": "steedos-listview-change-button",
6687
7361
  "label": "\${listName ? uiSchema.list_views[listName].label : uiSchema.list_views[defaultListName].label}",
6688
7362
  "rightIcon": "fa fa-caret-down",
6689
7363
  "size": "sm",
6690
7364
  "hideCaret": true,
6691
7365
  "closeOnClick": true,
6692
7366
  "btnClassName": "!bg-transparent !border-none !hover:border-none text-lg h-5 font-bold p-0 text-black leading-none",
6693
- "buttons": listViewButtonOptions
7367
+ "buttons": [
7368
+ ...listViewButtonOptions,
7369
+ listviewNewButton
7370
+ ]
6694
7371
  }
6695
7372
  ],
6696
7373
  "md": "",
@@ -7218,216 +7895,6 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
7218
7895
  async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
7219
7896
  }
7220
7897
 
7221
- const getNewListviewButtonSchema = ()=>{
7222
- return {
7223
- "type": "button",
7224
- "label": i18next.t('frontend_listview_control_new_label'),
7225
- "onEvent": {
7226
- "click": {
7227
- "weight": 0,
7228
- "actions": [
7229
- {
7230
- "dialog": {
7231
- "type": "dialog",
7232
- "title": i18next.t('frontend_listview_control_new_title'),
7233
- "data": {
7234
- //"&":"$$",2.7、2.9、3.0在此处失效
7235
- "all": "${uiSchema.list_views.all}",
7236
- "list_view": "${uiSchema.list_views[listName]}",
7237
- "appId": "${appId}",
7238
- "global": "${global}",
7239
- "targetObjectName": "${objectName}",
7240
- "context": "${context}"
7241
- },
7242
- "body": [
7243
- {
7244
- "type": "steedos-object-form",
7245
- "label": "对象表单",
7246
- "objectApiName": "object_listviews",
7247
- "recordId": "",
7248
- "mode": "edit",
7249
- "layout": "normal",
7250
- "defaultData": {
7251
- "&": "${list_view}",
7252
- "name":"",
7253
- "label":"",
7254
- "filters":"",
7255
- "shared":false,
7256
- "object_name": "${targetObjectName}",
7257
- "_id":"",
7258
- "shared_to": null,
7259
- "shared_to_organizations": null,
7260
- "locked": false,
7261
- "owner": null,
7262
- "company_id": null,
7263
- "company_ids": null,
7264
- "is_system": false
7265
- },
7266
- "fieldsExtend": fieldsExtend$5(),
7267
- "fields": fields$1(),
7268
- "onEvent": {
7269
- "submitSucc": {
7270
- "weight": 0,
7271
- "actions": [
7272
- {
7273
- "args": {
7274
- // 直接使用recordId不能拿到数据,只能通过result里面拿数据
7275
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
7276
- "blank": false
7277
- },
7278
- "actionType": "url",
7279
- }
7280
- ]
7281
- }
7282
- },
7283
- "messages": {
7284
- "success": i18next.t('frontend_listview_control_new_message_success'),
7285
- "failed": i18next.t('frontend_listview_control_new_message_failed')
7286
- },
7287
- }
7288
- ],
7289
- "showCloseButton": true,
7290
- "showErrorMsg": true,
7291
- "showLoading": true,
7292
- "closeOnEsc": false,
7293
- "dataMapSwitch": false,
7294
- "size": "lg"
7295
- },
7296
- "actionType": "dialog"
7297
- }
7298
- ]
7299
- }
7300
- }
7301
- }
7302
- };
7303
-
7304
- function fields$1(){
7305
- return [
7306
- "label",
7307
- "name",
7308
- "object_name",
7309
- "filter_scope",
7310
- "show_count",
7311
- "columns",
7312
- "sort",
7313
- "filters",
7314
- "mobile_columns",
7315
- "searchable_fields",
7316
- "is_system",
7317
- "shared",
7318
- "shared_to",
7319
- "shared_to_organizations"
7320
- ]
7321
- }
7322
-
7323
- function fieldsExtend$5(){
7324
- return {
7325
- "group": "",
7326
- "label": {
7327
- "group": "",
7328
- "is_wide": true
7329
- },
7330
- "name": {
7331
- "group": "",
7332
- "amis": {
7333
- "hidden": true,
7334
- "required": false
7335
- }
7336
- },
7337
- "object_name": {
7338
- "group": "",
7339
- "amis": {
7340
- "hidden": true
7341
- }
7342
- },
7343
- "filter_scope": {
7344
- "group": "",
7345
- "amis": {
7346
- "hidden": true,
7347
- "required": false
7348
- }
7349
- },
7350
- "columns": {
7351
- "group": "",
7352
- "amis": {
7353
- "hidden": true,
7354
- "required": false
7355
- }
7356
- },
7357
- "mobile_columns":{
7358
- "group": "",
7359
- "amis": {
7360
- "hidden": true,
7361
- "required": false
7362
- }
7363
- },
7364
- "searchable_fields":{
7365
- "group": "",
7366
- "amis": {
7367
- "hidden": true,
7368
- "required": false
7369
- }
7370
- },
7371
- "filter_fields": {
7372
- "group": "",
7373
- "amis": {
7374
- "hidden": true,
7375
- "required": false
7376
- }
7377
- },
7378
- "scrolling_mode": {
7379
- "group": "",
7380
- "amis": {
7381
- "hidden": true,
7382
- "required": false
7383
- }
7384
- },
7385
- "sort": {
7386
- "group": "",
7387
- "amis": {
7388
- "hidden": true,
7389
- "required": false
7390
- }
7391
- },
7392
- "show_count": {
7393
- "group": "",
7394
- "amis": {
7395
- "hidden": true,
7396
- "required": false
7397
- }
7398
- },
7399
- "type": {
7400
- "group": "",
7401
- "amis": {
7402
- "hidden": true,
7403
- "required": false
7404
- }
7405
- },
7406
- "shared": {
7407
- "group": "",
7408
- "amis": {
7409
- "visibleOn": "${false}"
7410
- }
7411
- },
7412
- "shared_to": {
7413
- "group": "",
7414
- "amis":{
7415
- "type": "radios",
7416
- "inline": false
7417
- }
7418
- },
7419
- "shared_to_organizations": {
7420
- "group": ""
7421
- },
7422
- "filters": {
7423
- "group": "",
7424
- "amis": {
7425
- "hidden": true
7426
- }
7427
- }
7428
- }
7429
- }
7430
-
7431
7898
  const getCopyListviewButtonSchema = ()=>{
7432
7899
  return {
7433
7900
  "type": "button",