@steedos-widgets/amis-lib 1.2.6-beta.18 → 1.2.6-beta.20

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
@@ -2658,6 +2658,35 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2658
2658
  // }
2659
2659
  // listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
2660
2660
  `;
2661
+ const onResetScript = `
2662
+ const scope = event.context.scoped;
2663
+ var filterForm = scope.parent.parent.getComponents().find(function(n){
2664
+ return n.props.type === "form";
2665
+ });
2666
+ var filterFormValues = filterForm.getValues();
2667
+ var listView = scope.parent.parent.parent.getComponents().find(function(n){
2668
+ return n.props.type === "crud";
2669
+ });
2670
+ const removedValues = {};
2671
+ for(var k in filterFormValues){
2672
+ if(/^__searchable__/.test(k)){
2673
+ removedValues[k] = "";
2674
+ }
2675
+ }
2676
+ if(!event.data.isLookup){
2677
+ // 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
2678
+ const listViewId = event.data.listViewId;
2679
+ const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
2680
+ let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
2681
+ if(localListViewProps){
2682
+ localListViewProps = JSON.parse(localListViewProps);
2683
+ for(var k in localListViewProps){
2684
+ removedValues[k] = "";
2685
+ }
2686
+ }
2687
+ }
2688
+ listView.handleFilterSubmit(removedValues);
2689
+ `;
2661
2690
  const dataProviderInited = `
2662
2691
  const objectName = data.objectName;
2663
2692
  const isLookup = data.isLookup;
@@ -2851,6 +2880,21 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2851
2880
  }
2852
2881
  }
2853
2882
  },
2883
+ {
2884
+ "type": "button",
2885
+ "label": "重置",
2886
+ "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
2887
+ "onEvent": {
2888
+ "click": {
2889
+ "actions": [
2890
+ {
2891
+ "actionType": "custom",
2892
+ "script": onResetScript
2893
+ }
2894
+ ]
2895
+ }
2896
+ }
2897
+ },
2854
2898
  {
2855
2899
  "type": "button",
2856
2900
  "label": "设置搜索项",
@@ -3671,7 +3715,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3671
3715
  "list_view": "${uiSchema.list_views[listName]}",
3672
3716
  "appId": "${appId}",
3673
3717
  "global": "${global}",
3674
- "objectName": "${objectName}",
3718
+ "targetObjectName": "${objectName}",
3675
3719
  },
3676
3720
  "body": [
3677
3721
  {
@@ -3711,7 +3755,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3711
3755
  {
3712
3756
  "args": {
3713
3757
  // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3714
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/listview_${result.data.recordId|lowerCase}",
3758
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3715
3759
  "blank": false
3716
3760
  },
3717
3761
  "actionType": "url",
@@ -3752,7 +3796,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3752
3796
  "data": {
3753
3797
  "&": "$$",
3754
3798
  "listName": "${listName}",
3755
- "objectName": "${objectName}",
3799
+ "targetObjectName": "${objectName}",
3756
3800
  "list_view": "${uiSchema.list_views[listName]}",
3757
3801
  "appId": "${appId}",
3758
3802
  "global": "${global}"
@@ -3795,7 +3839,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3795
3839
  "actions": [
3796
3840
  {
3797
3841
  "args": {
3798
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/listview_${result.data.recordId|lowerCase}",
3842
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3799
3843
  "blank": false
3800
3844
  },
3801
3845
  "actionType": "url",
@@ -3831,7 +3875,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3831
3875
  "type": "dialog",
3832
3876
  "title": "重命名 列表视图",
3833
3877
  "data": {
3834
- "objectName": "${objectName}",
3878
+ "targetObjectName": "${objectName}",
3835
3879
  "recordId": "${uiSchema.list_views[listName]._id}",
3836
3880
  "appId": "${appId}"
3837
3881
  },
@@ -3852,7 +3896,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3852
3896
  "actions": [
3853
3897
  {
3854
3898
  "args": {
3855
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${name}",
3899
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
3856
3900
  "blank": false
3857
3901
  },
3858
3902
  "actionType": "url",
@@ -3926,6 +3970,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3926
3970
  "type": "dialog",
3927
3971
  "title": "过滤设置",
3928
3972
  "data": {
3973
+ "targetObjectName": "${objectName}",
3929
3974
  "objectName": "${objectName}",
3930
3975
  "recordId": "${uiSchema.list_views[listName]._id}",
3931
3976
  "listName": "${listName}",
@@ -3951,7 +3996,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3951
3996
  "actions": [
3952
3997
  {
3953
3998
  "args": {
3954
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
3999
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
3955
4000
  "blank": false
3956
4001
  },
3957
4002
  "actionType": "url",
@@ -3989,6 +4034,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3989
4034
  "title": "显示的列",
3990
4035
  "data": {
3991
4036
  "&": "$$",
4037
+ "targetObjectName": "${objectName}",
3992
4038
  "objectName": "${objectName}",
3993
4039
  "recordId": "${uiSchema.list_views[listName]._id}",
3994
4040
  "listName": "${listName}",
@@ -4014,7 +4060,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
4014
4060
  "actions": [
4015
4061
  {
4016
4062
  "args": {
4017
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4063
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4018
4064
  "blank": false
4019
4065
  },
4020
4066
  "actionType": "url"
@@ -4050,6 +4096,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
4050
4096
  "title": "弹框标题",
4051
4097
  "data": {
4052
4098
  "&": "$$",
4099
+ "targetObjectName": "${objectName}",
4053
4100
  "objectName": "${objectName}",
4054
4101
  "recordId": "${uiSchema.list_views[listName]._id}",
4055
4102
  "listName": "${listName}",
@@ -4075,7 +4122,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
4075
4122
  "actions": [
4076
4123
  {
4077
4124
  "args": {
4078
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4125
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4079
4126
  "blank": false
4080
4127
  },
4081
4128
  "actionType": "url"
@@ -4976,11 +5023,12 @@ async function lookupToAmisSelect(field, readonly, ctx){
4976
5023
  autoComplete: apiInfo,
4977
5024
  searchable: true,
4978
5025
  };
5026
+ //删除xlink:href中的rootUrl前缀,解决客户端svg为空的问题
4979
5027
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
4980
5028
  <span role='img' aria-label='smile' class='anticon anticon-smile'>
4981
5029
  <span class='slds-icon_container slds-icon-standard-\${REPLACE(icon,'_','-')}'>
4982
5030
  <svg class='slds-icon slds-icon_x-small' aria-hidden='true'>
4983
- <use xlink:href='\${context.rootUrl}/assets/icons/standard-sprite/svg/symbols.svg#\${icon}'></use>
5031
+ <use xlink:href='/assets/icons/standard-sprite/svg/symbols.svg#\${icon}'></use>
4984
5032
  </svg>
4985
5033
  </span>
4986
5034
  </span>
@@ -7025,8 +7073,9 @@ async function getMobileTableColumns(fields, options){
7025
7073
  const url = getNameTplUrl(nameField, options);
7026
7074
 
7027
7075
  const columnLines = getMobileLines(tpls);
7028
-
7029
- columns.push({
7076
+
7077
+
7078
+ let column = {
7030
7079
  name: nameField.name,
7031
7080
  label: nameField.label,
7032
7081
  sortable: nameField.sortable,
@@ -7035,13 +7084,66 @@ async function getMobileTableColumns(fields, options){
7035
7084
  actionType: "link",
7036
7085
  link: url,
7037
7086
  innerClassName: "steedos-listview-item block text-gray-500",
7038
- body:{
7087
+ body: {
7039
7088
  "type": "wrapper",
7040
7089
  "body": columnLines,
7041
7090
  "size": "none",
7042
7091
  "className": "p-1"
7043
7092
  }
7044
- });
7093
+ };
7094
+
7095
+ if(options.objectName === 'cms_files'){
7096
+ if(window.Meteor?.isCordova){
7097
+ column = {
7098
+ ...column,
7099
+ actionType: "",
7100
+ link: "",
7101
+ onEvent: {
7102
+ "click": {
7103
+ "actions": [
7104
+ {
7105
+ "script": `
7106
+ let cms_url = "/api/files/files/"+event.data.versions[0]+"?download=true"
7107
+ Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
7108
+ `,
7109
+ "actionType": "custom"
7110
+ }
7111
+ ],
7112
+ "weight": 0
7113
+ }
7114
+ }
7115
+ };
7116
+ }else {
7117
+ column = {
7118
+ ...column,
7119
+ actionType: "",
7120
+ link: "",
7121
+ onEvent: {
7122
+ "click": {
7123
+ "actions": [
7124
+ {
7125
+ "args": {
7126
+ "api": {
7127
+ "url": url,
7128
+ "method": "get",
7129
+ "headers": {
7130
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
7131
+ }
7132
+ }
7133
+ },
7134
+ "actionType": "download"
7135
+ }
7136
+ ],
7137
+ "weight": 0
7138
+ }
7139
+ }
7140
+ };
7141
+ }
7142
+
7143
+ }
7144
+
7145
+ columns.push(column);
7146
+
7045
7147
 
7046
7148
  return columns;
7047
7149
  }
@@ -8132,7 +8234,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
8132
8234
  * @Author: baozhoutao@steedos.com
8133
8235
  * @Date: 2022-07-05 15:55:39
8134
8236
  * @LastEditors: Please set LastEditors
8135
- * @LastEditTime: 2023-04-20 11:43:14
8237
+ * @LastEditTime: 2023-05-08 16:34:25
8136
8238
  * @Description:
8137
8239
  */
8138
8240
 
@@ -8386,7 +8488,7 @@ function getDefaultRelatedListProps(uiSchema, listName, ctx) {
8386
8488
  }
8387
8489
  function getRelatedListProps(uiSchema, listViewName, ctx) {
8388
8490
  if (ctx.columns) {
8389
- const sort = getListViewSort(ctx.sort);
8491
+ const sort = getListViewSort({sort: ctx.sort});
8390
8492
  let { filters , filtersFunction} = ctx;
8391
8493
  if(!filtersFunction && filters){
8392
8494
  filtersFunction = str2function(