mirror of
https://github.com/steedos/steedos-platform
synced 2024-11-22 17:06:42 +00:00
相关表列表支持显示自定义按钮 #2697
This commit is contained in:
parent
3e31a125d8
commit
fb972b5aa5
@ -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)
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user