From fb972b5aa5f8f93015cf5c301ee0c0c57be070cf Mon Sep 17 00:00:00 2001 From: baozhoutao Date: Sat, 15 Jan 2022 11:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B8=E5=85=B3=E8=A1=A8=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=98=BE=E7=A4=BA=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=8C=89=E9=92=AE=20#2697?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/views/related_object_list.coffee | 26 +++++++++++++++- .../client/views/related_object_list.html | 30 ++++++++++++------- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/creator/packages/steedos-creator/client/views/related_object_list.coffee b/creator/packages/steedos-creator/client/views/related_object_list.coffee index fafcbf8a99..295e5936d2 100644 --- a/creator/packages/steedos-creator/client/views/related_object_list.coffee +++ b/creator/packages/steedos-creator/client/views/related_object_list.coffee @@ -50,6 +50,11 @@ Template.related_object_list.helpers return false related_list_item_props = getRelateObj() return Creator.getRecordRelatedListPermissions(object_name, related_list_item_props)[key] + newAction: ()-> + return this.name == 'standard_new' + actions: ()-> + related_object_name = Session.get "related_object_name" + return Creator.getRelatedObjectListActions(related_object_name); isUnlocked: ()-> if Creator.getPermissions(Session.get('object_name')).modifyAllRecords @@ -132,8 +137,27 @@ Template.related_object_list.helpers recordsTotal = Template.instance().recordsTotal return (event)-> recordsTotal?.set(event.api.getDisplayedRowCount()) - +isCalendarView = ()-> + view = Creator.getListView(Session.get "related_object_name", Session.get("list_view_id")) + return view?.type == 'calendar' Template.related_object_list.events + 'click .list-action-custom': (event) -> + objectName = Session.get("related_object_name") + object = Creator.getObject(objectName) + collection_name = object.label + Session.set("action_fields", undefined) + Session.set("action_collection", "Creator.Collections.#{objectName}") + Session.set("action_collection_name", collection_name) + if isCalendarView() + Session.set("action_save_and_insert", false) + else + Session.set("action_save_and_insert", true) + # 底层 standard_delete_many 函数强依赖了session变量,此处只能变通处理。 + if this.name == "standard_delete_many" + listViewName = getListviewName() + Creator.executeAction(objectName, {todo: 'standard_delete'}, null, null, listViewName) + else + Creator.executeAction objectName, this "click .add-related-object-record": (event, template)-> related_object_name = Session.get "related_object_name" relateObject = Creator.getObject(related_object_name) diff --git a/creator/packages/steedos-creator/client/views/related_object_list.html b/creator/packages/steedos-creator/client/views/related_object_list.html index e093744e22..d973cb3514 100644 --- a/creator/packages/steedos-creator/client/views/related_object_list.html +++ b/creator/packages/steedos-creator/client/views/related_object_list.html @@ -28,24 +28,34 @@

- {{#if perms "allowCreate"}} - {{#if is_file}} + {{#if is_file}} + {{#if perms "allowCreate"}} {{#if recordPerminssion "allowCreateFiles"}} {{/if}} - {{else}} - {{/if}} - {{/if}} - {{#if perms "allowDelete"}} - + {{else}} + {{#each actions}} + {{#if newAction}} + + {{else}} +
  • + +
    {{this.label}}
    +
    +
  • + {{/if}} + {{/each}} {{/if}}