mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 05:34:55 +08:00
Merge pull request #8113 from aignatov-bio/ai-sci-11405-add-archive-restore-actions-to-forms
Add archive and restore actions to forms table [SCI-11405]
This commit is contained in:
commit
3701a974a1
5 changed files with 62 additions and 2 deletions
|
@ -5,9 +5,14 @@
|
|||
:dataUrl="dataSource"
|
||||
:reloadingTable="reloadingTable"
|
||||
:toolbarActions="toolbarActions"
|
||||
:activePageUrl="activePageUrl"
|
||||
:archivedPageUrl="archivedPageUrl"
|
||||
:currentViewMode="currentViewMode"
|
||||
:actionsUrl="actionsUrl"
|
||||
@tableReloaded="reloadingTable = false"
|
||||
@create="createForm"
|
||||
@archive="archive"
|
||||
@restore="restore"
|
||||
@access="access"
|
||||
/>
|
||||
</div>
|
||||
|
@ -52,7 +57,10 @@ export default {
|
|||
userRolesUrl: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
activePageUrl: { type: String },
|
||||
archivedPageUrl: { type: String },
|
||||
currentViewMode: { type: String, required: true }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -129,6 +137,22 @@ export default {
|
|||
object: rows[0],
|
||||
roles_path: this.userRolesUrl
|
||||
};
|
||||
},
|
||||
archive(event) {
|
||||
axios.post(event.path).then((response) => {
|
||||
this.reloadingTable = true;
|
||||
HelperModule.flashAlertMsg(response.data.message, 'success');
|
||||
}).catch((error) => {
|
||||
HelperModule.flashAlertMsg(error.response.data.error, 'danger');
|
||||
});
|
||||
},
|
||||
restore(event) {
|
||||
axios.post(event.path).then((response) => {
|
||||
this.reloadingTable = true;
|
||||
HelperModule.flashAlertMsg(response.data.message, 'success');
|
||||
}).catch((error) => {
|
||||
HelperModule.flashAlertMsg(error.response.data.error, 'danger');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -9,6 +9,11 @@ module Lists
|
|||
|
||||
def fetch_records
|
||||
@records = Form.where(team: @team).readable_by_user(@user)
|
||||
|
||||
view_mode = @params[:view_mode] || 'active'
|
||||
|
||||
@records = @records.archived if view_mode == 'archived'
|
||||
@records = @records.active if view_mode == 'active'
|
||||
end
|
||||
|
||||
def filter_records; end
|
||||
|
|
|
@ -18,7 +18,9 @@ module Toolbars
|
|||
return [] if @forms.none?
|
||||
|
||||
[
|
||||
access_action
|
||||
access_action,
|
||||
archive_action,
|
||||
restore_action
|
||||
].compact
|
||||
end
|
||||
|
||||
|
@ -34,5 +36,29 @@ module Toolbars
|
|||
type: :emit
|
||||
}
|
||||
end
|
||||
|
||||
def archive_action
|
||||
return unless @forms.all? { |form| can_archive_form?(form) }
|
||||
|
||||
{
|
||||
name: 'archive',
|
||||
label: I18n.t('forms.index.toolbar.archive'),
|
||||
icon: 'sn-icon sn-icon-archive',
|
||||
path: archive_forms_path(form_ids: @forms.pluck(:id)),
|
||||
type: :emit
|
||||
}
|
||||
end
|
||||
|
||||
def restore_action
|
||||
return unless @forms.all? { |form| can_restore_form?(form) }
|
||||
|
||||
{
|
||||
name: 'restore',
|
||||
label: I18n.t('forms.index.toolbar.restore'),
|
||||
icon: 'sn-icon sn-icon-restore',
|
||||
path: restore_forms_path(form_ids: @forms.pluck(:id)),
|
||||
type: :emit
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
data-source="<%= forms_path(format: :json) %>"
|
||||
create-url="<%= forms_path %>"
|
||||
user-roles-url="<%= user_roles_forms_path %>"
|
||||
active-page-url="<%= forms_path(view_mode: :active) %>"
|
||||
archived-page-url="<%= forms_path(view_mode: :archived) %>"
|
||||
current-view-mode="<%= params[:view_mode] || :active %>"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1075,6 +1075,8 @@ en:
|
|||
toolbar:
|
||||
new: 'New form'
|
||||
access: 'Access'
|
||||
archive: 'Archive'
|
||||
restore: 'Restore'
|
||||
table:
|
||||
name: 'Form name'
|
||||
code: 'ID'
|
||||
|
|
Loading…
Add table
Reference in a new issue