@steedos-widgets/amis-object 6.3.0-beta.14 → 6.3.0-beta.15

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.
@@ -2580,6 +2580,27 @@ body.sidebar #sidebar {
2580
2580
  background: rgba(0, 0, 0, 0.6);
2581
2581
  opacity: 1;
2582
2582
  }
2583
+ .steedos-header-toolbar-notifications-dialog .antd-Modal-content {
2584
+ position: absolute !important;
2585
+ left: 12px;
2586
+ right: 12px;
2587
+ top: 50px;
2588
+ height: auto !important;
2589
+ width: unset;
2590
+ max-width: unset;
2591
+ border-radius: var(--dialog-default-border-radius) !important;
2592
+ padding: 0;
2593
+ background: transparent;
2594
+ border: none;
2595
+ }
2596
+ .steedos-header-toolbar-notifications-dialog .antd-Modal-content .antd-Modal-body {
2597
+ padding: 0;
2598
+ margin: 0;
2599
+ }
2600
+ .steedos-header-toolbar-notifications-dialog .antd-Modal-content .antd-Modal-body .steedos-header-toolbar-notifications-panel .steedos-header-toolbar-notifications-list {
2601
+ max-height: 60vh;
2602
+ margin: 0;
2603
+ }
2583
2604
  }
2584
2605
 
2585
2606
  .instance-default .instance-form .form-control .antd-Form-item {
@@ -4540,6 +4540,7 @@ var frontend_setup$1 = "Setup";
4540
4540
  var frontend_notifications$1 = "Notifications";
4541
4541
  var frontend_notifications_allread$1 = "Mark all as read";
4542
4542
  var frontend_notifications_allread_message$1 = "All marked as read";
4543
+ var frontend_notifications_close_dialog$1 = "Close";
4543
4544
  var frontend_profile$1 = "Profile";
4544
4545
  var switch_space$1 = "Switch Space";
4545
4546
  var frontend_about$1 = "About";
@@ -4629,6 +4630,7 @@ var en_us = {
4629
4630
  frontend_notifications: frontend_notifications$1,
4630
4631
  frontend_notifications_allread: frontend_notifications_allread$1,
4631
4632
  frontend_notifications_allread_message: frontend_notifications_allread_message$1,
4633
+ frontend_notifications_close_dialog: frontend_notifications_close_dialog$1,
4632
4634
  frontend_profile: frontend_profile$1,
4633
4635
  switch_space: switch_space$1,
4634
4636
  frontend_about: frontend_about$1,
@@ -4720,6 +4722,7 @@ var frontend_setup = "设置";
4720
4722
  var frontend_notifications = "通知";
4721
4723
  var frontend_notifications_allread = "全部标记为已读";
4722
4724
  var frontend_notifications_allread_message = "已全部标记为已读";
4725
+ var frontend_notifications_close_dialog = "关闭";
4723
4726
  var frontend_profile = "个人资料";
4724
4727
  var switch_space = "切换工作区";
4725
4728
  var frontend_about = "关于";
@@ -4810,6 +4813,7 @@ var zh_cn = {
4810
4813
  frontend_notifications: frontend_notifications,
4811
4814
  frontend_notifications_allread: frontend_notifications_allread,
4812
4815
  frontend_notifications_allread_message: frontend_notifications_allread_message,
4816
+ frontend_notifications_close_dialog: frontend_notifications_close_dialog,
4813
4817
  frontend_profile: frontend_profile,
4814
4818
  switch_space: switch_space,
4815
4819
  frontend_about: frontend_about,
@@ -22759,9 +22763,218 @@ var AmisGlobalFooter = function (props) { return __awaiter(void 0, void 0, void
22759
22763
  * @Author: baozhoutao@steedos.com
22760
22764
  * @Date: 2022-09-01 14:44:57
22761
22765
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
22762
- * @LastEditTime: 2024-05-24 15:28:23
22766
+ * @LastEditTime: 2024-05-24 19:37:30
22763
22767
  * @Description:
22764
22768
  */
22769
+ var getNotificationBadgeButton = function () {
22770
+ var isMobile = window.innerWidth < 768;
22771
+ var listContent = {
22772
+ "type": "service",
22773
+ "body": [
22774
+ {
22775
+ "type": "panel",
22776
+ "title": instance.t('frontend_notifications'),
22777
+ "className": "steedos-header-toolbar-notifications-panel " + (isMobile ? "" : "min-w-[300px] max-w-md"),
22778
+ "body": [
22779
+ {
22780
+ "type": "each",
22781
+ "className": "overflow-auto max-h-96 steedos-header-toolbar-notifications-list",
22782
+ "name": "notifications",
22783
+ "items": {
22784
+ "type": "tpl",
22785
+ "tpl": "<div class='flex items-center p-4 hover:bg-sky-50'>\n <img src='<%=data.context.rootUrl + \"/avatar/\" + data.from%>' alt='' class='h-10 w-10 flex-none rounded-full'>\n <div class='ml-4 flex-auto'>\n <div class='font-medium'>\n <span class='text-primary'><%=data.name%></span>\n </div>\n <div class='mt-1 text-gray-700'>\n <%=data.body%>\n </div>\n <div class='mt-1 text-gray-700'>\n <%=moment(data.created).locale(data.global.user.language).fromNow()%>\n <abbr class='slds-text-link slds-m-horizontal_xxx-small <%=data.is_read ? 'hidden' : ''%>' title='unread'>\u25CF</abbr>\n </div>\n </div>\n </div>",
22786
+ "id": "u:07ece657c7b7",
22787
+ "onEvent": {
22788
+ "click": {
22789
+ "weight": 0,
22790
+ "actions": [
22791
+ {
22792
+ "args": {
22793
+ "options": {},
22794
+ "api": {
22795
+ "url": "${context.rootUrl}/api/v4/notifications/${_id}/read?rootUrl=&appId=${appId}&async=true",
22796
+ "method": "get",
22797
+ "messages": {},
22798
+ "headers": {
22799
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
22800
+ },
22801
+ "adaptor": "payload = {\n status: 0,\n msg: '',\n data: {\n redirect: payload.redirect || payload \n }} \nreturn payload;"
22802
+ // "adaptor": notificationReadAdaptor
22803
+ }
22804
+ },
22805
+ "actionType": "ajax"
22806
+ },
22807
+ // {
22808
+ // "actionType": "custom",
22809
+ // "script": "if(Meteor.isCordova){window.open(Meteor.absoluteUrl(event.data.responseResult.responseData.redirect), '_blank')}else{window.open(event.data.responseResult.responseData.redirect, '_blank')}",
22810
+ // "expression": "${!!event.data.responseResult.responseData.redirect}",
22811
+ // },
22812
+ {
22813
+ // PC端保持原样,新窗口打开
22814
+ "actionType": "custom",
22815
+ "script": "window.open(event.data.responseResult.responseData.redirect, '_blank')",
22816
+ "expression": "${!!event.data.responseResult.responseData.redirect && window:innerWidth > 768}"
22817
+ },
22818
+ {
22819
+ // 手机端改为直接跳路由,因为新窗口打开顶部会显示url地址栏
22820
+ "actionType": "link",
22821
+ "args": {
22822
+ "link": "${redirect}"
22823
+ },
22824
+ "expression": "${!!event.data.responseResult.responseData.redirect && window:innerWidth <= 768}"
22825
+ },
22826
+ {
22827
+ "actionType": "cancel",
22828
+ "componentId": "steedos_header_toolbar_notifications_dialog",
22829
+ "expression": "${!!event.data.responseResult.responseData.redirect && window:innerWidth <= 768}"
22830
+ }
22831
+ ]
22832
+ }
22833
+ }
22834
+ },
22835
+ "id": "u:18da41dab9ca"
22836
+ },
22837
+ ],
22838
+ actions: [
22839
+ {
22840
+ "type": "button",
22841
+ "label": instance.t('frontend_notifications_close_dialog'),
22842
+ "visibleOn": "${window:innerWidth <= 768}",
22843
+ "close": true
22844
+ },
22845
+ {
22846
+ "type": "button",
22847
+ "label": instance.t('frontend_notifications_allread'),
22848
+ "id": "u:5530f3779e3a",
22849
+ "onEvent": {
22850
+ "click": {
22851
+ "actions": [
22852
+ {
22853
+ "componentId": "",
22854
+ "args": {
22855
+ "api": {
22856
+ "url": "${context.rootUrl}/api/v4/notifications/all/markReadAll",
22857
+ "method": "post",
22858
+ "headers": {
22859
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
22860
+ }
22861
+ },
22862
+ "messages": {
22863
+ "success": instance.t('frontend_notifications_allread_message')
22864
+ }
22865
+ },
22866
+ "actionType": "ajax"
22867
+ }
22868
+ ],
22869
+ "weight": 0
22870
+ }
22871
+ }
22872
+ }
22873
+ ]
22874
+ },
22875
+ ],
22876
+ "id": "u:aba521eed5b7",
22877
+ "onEvent": {
22878
+ "@data.changed.notifications": {
22879
+ "actions": [
22880
+ {
22881
+ "actionType": "reload"
22882
+ }
22883
+ ]
22884
+ }
22885
+ },
22886
+ "messages": {},
22887
+ "api": {
22888
+ "method": "post",
22889
+ "url": "${context.rootUrl}/graphql",
22890
+ "data": {
22891
+ "&": "$$",
22892
+ "context": "${context}",
22893
+ "userId": "${context.userId}"
22894
+ },
22895
+ "dataType": "json",
22896
+ "requestAdaptor": "const { userId } = api.data;\napi.data = {\n query: `{\n notifications(filters: [\"owner\",\"=\",\"${userId}\"], sort: \"created desc,name\", top : 10){\n _id,name,body,related_to,related_name,url,owner,is_read,from,created\n } }`\n}",
22897
+ "headers": {
22898
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
22899
+ },
22900
+ "adaptor": "return payload.data"
22901
+ },
22902
+ };
22903
+ var badgeButtonContent = {
22904
+ "type": "service",
22905
+ "body": [
22906
+ {
22907
+ "type": "steedos-badge",
22908
+ "body": [
22909
+ {
22910
+ "type": "steedos-icon",
22911
+ "category": "utility",
22912
+ "name": "notification",
22913
+ "colorVariant": "default",
22914
+ "className": "slds-button_icon slds-global-header__icon"
22915
+ }
22916
+ ],
22917
+ "count": "${unReadCount}"
22918
+ },
22919
+ ],
22920
+ "id": "u:aba521eed5b7",
22921
+ "messages": {},
22922
+ "api": {
22923
+ "method": "post",
22924
+ "url": "${context.rootUrl}/graphql",
22925
+ "data": {
22926
+ "&": "$$",
22927
+ "context": "${context}",
22928
+ "userId": "${context.userId}"
22929
+ },
22930
+ "dataType": "json",
22931
+ "requestAdaptor": "const { userId } = api.data;\napi.data = {\n query: `{\n unReadCount: notifications__count(filters: [[\"owner\",\"=\",\"${userId}\"], [\"is_read\", \"!=\", true]])\n }`\n}",
22932
+ "headers": {
22933
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
22934
+ },
22935
+ "adaptor": "return payload.data"
22936
+ },
22937
+ "onEvent": {
22938
+ "@data.changed.notifications": {
22939
+ "actions": [
22940
+ {
22941
+ "actionType": "reload"
22942
+ }
22943
+ ]
22944
+ }
22945
+ },
22946
+ // "interval": 30000,
22947
+ "silentPolling": true
22948
+ };
22949
+ return isMobile ? {
22950
+ "type": "button",
22951
+ "body": badgeButtonContent,
22952
+ "actionType": "dialog",
22953
+ "dialog": {
22954
+ "title": "",
22955
+ "id": "steedos_header_toolbar_notifications_dialog",
22956
+ "className": "steedos-header-toolbar-notifications-dialog",
22957
+ "body": listContent,
22958
+ "actions": [],
22959
+ "showCloseButton": false,
22960
+ "closeOnOutside": true
22961
+ }
22962
+ } : {
22963
+ "type": "steedos-dropdown",
22964
+ "placement": "bottomRight",
22965
+ "trigger": [
22966
+ "click"
22967
+ ],
22968
+ "body": [
22969
+ badgeButtonContent
22970
+ ],
22971
+ "overlay": [
22972
+ listContent
22973
+ ],
22974
+ "className": "antd-Action steedos-header-toolbar-notifications",
22975
+ "open": false
22976
+ };
22977
+ };
22765
22978
  var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0, void 0, function () {
22766
22979
  var _a, className, data, _b, logoutScript, _c, customButtons, avatarSrc;
22767
22980
  var _d, _e;
@@ -22913,187 +23126,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
22913
23126
  }
22914
23127
  ]
22915
23128
  },
22916
- {
22917
- "type": "steedos-dropdown",
22918
- "placement": "bottomRight",
22919
- "trigger": [
22920
- "click"
22921
- ],
22922
- "body": [
22923
- {
22924
- "type": "service",
22925
- "body": [
22926
- {
22927
- "type": "steedos-badge",
22928
- "body": [
22929
- {
22930
- "type": "steedos-icon",
22931
- "category": "utility",
22932
- "name": "notification",
22933
- "colorVariant": "default",
22934
- "className": "slds-button_icon slds-global-header__icon"
22935
- }
22936
- ],
22937
- "count": "${unReadCount}"
22938
- },
22939
- ],
22940
- "id": "u:aba521eed5b7",
22941
- "messages": {},
22942
- "api": {
22943
- "method": "post",
22944
- "url": "${context.rootUrl}/graphql",
22945
- "data": {
22946
- "&": "$$",
22947
- "context": "${context}",
22948
- "userId": "${context.userId}"
22949
- },
22950
- "dataType": "json",
22951
- "requestAdaptor": "const { userId } = api.data;\napi.data = {\n query: `{\n unReadCount: notifications__count(filters: [[\"owner\",\"=\",\"${userId}\"], [\"is_read\", \"!=\", true]])\n }`\n}",
22952
- "headers": {
22953
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
22954
- },
22955
- "adaptor": "return payload.data"
22956
- },
22957
- "onEvent": {
22958
- "@data.changed.notifications": {
22959
- "actions": [
22960
- {
22961
- "actionType": "reload"
22962
- }
22963
- ]
22964
- }
22965
- },
22966
- // "interval": 30000,
22967
- "silentPolling": true
22968
- }
22969
- ],
22970
- "overlay": [
22971
- {
22972
- "type": "service",
22973
- "body": [
22974
- {
22975
- "type": "panel",
22976
- "title": instance.t('frontend_notifications'),
22977
- "className": "min-w-[300px] max-w-md",
22978
- "body": [
22979
- {
22980
- "type": "each",
22981
- className: "overflow-auto max-h-96",
22982
- "name": "notifications",
22983
- "items": {
22984
- "type": "tpl",
22985
- "tpl": "<div class='flex items-center p-4 hover:bg-sky-50'>\n <img src='<%=data.context.rootUrl + \"/avatar/\" + data.from%>' alt='' class='h-10 w-10 flex-none rounded-full'>\n <div class='ml-4 flex-auto'>\n <div class='font-medium'>\n <span class='text-primary'><%=data.name%></span>\n </div>\n <div class='mt-1 text-gray-700'>\n <%=data.body%>\n </div>\n <div class='mt-1 text-gray-700'>\n <%=moment(data.created).locale(data.global.user.language).fromNow()%>\n <abbr class='slds-text-link slds-m-horizontal_xxx-small <%=data.is_read ? 'hidden' : ''%>' title='unread'>\u25CF</abbr>\n </div>\n </div>\n </div>",
22986
- "id": "u:07ece657c7b7",
22987
- "onEvent": {
22988
- "click": {
22989
- "weight": 0,
22990
- "actions": [
22991
- {
22992
- "args": {
22993
- "options": {},
22994
- "api": {
22995
- "url": "${context.rootUrl}/api/v4/notifications/${_id}/read?rootUrl=&appId=${appId}&async=true",
22996
- "method": "get",
22997
- "messages": {},
22998
- "headers": {
22999
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
23000
- },
23001
- "adaptor": "payload = {\n status: 0,\n msg: '',\n data: {\n redirect: payload.redirect || payload \n }} \nreturn payload;"
23002
- // "adaptor": notificationReadAdaptor
23003
- }
23004
- },
23005
- "actionType": "ajax"
23006
- },
23007
- // {
23008
- // "actionType": "custom",
23009
- // "script": "if(Meteor.isCordova){window.open(Meteor.absoluteUrl(event.data.responseResult.responseData.redirect), '_blank')}else{window.open(event.data.responseResult.responseData.redirect, '_blank')}",
23010
- // "expression": "${!!event.data.responseResult.responseData.redirect}",
23011
- // },
23012
- {
23013
- // PC端保持原样,新窗口打开
23014
- "actionType": "custom",
23015
- "script": "window.open(event.data.responseResult.responseData.redirect, '_blank')",
23016
- "expression": "${!!event.data.responseResult.responseData.redirect && window:innerWidth > 768}",
23017
- },
23018
- {
23019
- // 手机端改为直接跳路由,因为新窗口打开顶部会显示url地址栏
23020
- "actionType": "link",
23021
- "args": {
23022
- "link": "${redirect}"
23023
- },
23024
- "expression": "${!!event.data.responseResult.responseData.redirect && window:innerWidth <= 768}",
23025
- }
23026
- ]
23027
- }
23028
- }
23029
- },
23030
- "id": "u:18da41dab9ca"
23031
- },
23032
- ],
23033
- actions: [
23034
- {
23035
- "type": "button",
23036
- "label": instance.t('frontend_notifications_allread'),
23037
- "id": "u:5530f3779e3a",
23038
- "onEvent": {
23039
- "click": {
23040
- "actions": [
23041
- {
23042
- "componentId": "",
23043
- "args": {
23044
- "api": {
23045
- "url": "${context.rootUrl}/api/v4/notifications/all/markReadAll",
23046
- "method": "post",
23047
- "headers": {
23048
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
23049
- }
23050
- },
23051
- "messages": {
23052
- "success": instance.t('frontend_notifications_allread_message')
23053
- }
23054
- },
23055
- "actionType": "ajax"
23056
- }
23057
- ],
23058
- "weight": 0
23059
- }
23060
- }
23061
- }
23062
- ]
23063
- },
23064
- ],
23065
- "id": "u:aba521eed5b7",
23066
- "onEvent": {
23067
- "@data.changed.notifications": {
23068
- "actions": [
23069
- {
23070
- "actionType": "reload"
23071
- }
23072
- ]
23073
- }
23074
- },
23075
- "messages": {},
23076
- "api": {
23077
- "method": "post",
23078
- "url": "${context.rootUrl}/graphql",
23079
- "data": {
23080
- "&": "$$",
23081
- "context": "${context}",
23082
- "userId": "${context.userId}"
23083
- },
23084
- "dataType": "json",
23085
- "requestAdaptor": "const { userId } = api.data;\napi.data = {\n query: `{\n notifications(filters: [\"owner\",\"=\",\"${userId}\"], sort: \"created desc,name\", top : 10){\n _id,name,body,related_to,related_name,url,owner,is_read,from,created\n } }`\n}",
23086
- "headers": {
23087
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
23088
- },
23089
- "adaptor": "return payload.data"
23090
- },
23091
- }
23092
- ],
23093
- "id": "u:857e8161c96b",
23094
- "className": "antd-Action steedos-header-toolbar-notifications",
23095
- "open": false
23096
- },
23129
+ getNotificationBadgeButton(),
23097
23130
  {
23098
23131
  "type": "steedos-dropdown",
23099
23132
  "placement": "bottomRight",