相关表列表支持显示自定义按钮 #2697

This commit is contained in:
baozhoutao 2022-01-15 11:37:30 +08:00
parent 3e31a125d8
commit fb972b5aa5
2 changed files with 45 additions and 11 deletions

View File

@ -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)

View File

@ -28,24 +28,34 @@ <h1 class="slds-page-header__title slds-text-color--default slds-p-right--x-smal
</div>
<div class="slds-col slds-no-flex slds-grid slds-align-top slds-p-bottom_xx-small">
<div class="slds-button-group" role="group">
{{#if perms "allowCreate"}}
{{#if is_file}}
{{#if is_file}}
{{#if perms "allowCreate"}}
{{#if recordPerminssion "allowCreateFiles"}}
<button class="slds-button slds-button_neutral btn-upload-file" title="{{_ "creator_actions_upload_file"}}">
{{_ "creator_actions_upload_file"}}
<input type="file" name="file" class="input-file-upload" data-target-object-name="cms_files" data-target-related-field-name="{{relatedFieldName}}">
</button>
{{/if}}
{{else}}
<button class="slds-button slds-button_neutral add-related-object-record" data-object-name="{{related_object_name}}" title="{{_ "New"}}">
{{_ "New"}}
{{/if}}
{{#if perms "allowDelete"}}
<button class="slds-button slds-button_neutral delete-related-object-record" data-object-name="{{related_object_name}}" title="{{_ "Delete"}}">
{{_ "Delete"}}
</button>
{{/if}}
{{/if}}
{{#if perms "allowDelete"}}
<button class="slds-button slds-button_neutral delete-related-object-record" data-object-name="{{related_object_name}}" title="{{_ "Delete"}}">
{{_ "Delete"}}
</button>
{{else}}
{{#each actions}}
{{#if newAction}}
<button class="slds-button slds-button_neutral add-related-object-record" data-object-name="{{related_object_name}}" title="{{_ "New"}}">
{{_ "New"}}
</button>
{{else}}
<li class="slds-button slds-button--neutral slds-truncate list-action-custom list-action-custom-{{this.name}}">
<a href="javascript:void(0);" title="{{this.label}}" class="">
<div class="slds-truncate" title="{{this.label}}">{{this.label}}</div>
</a>
</li>
{{/if}}
{{/each}}
{{/if}}
</div>
</div>