mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 00:24:42 +08:00
Add archive and restore actions to forms table [SCI-11405]
This commit is contained in:
parent
0d7d90f801
commit
4359e300b8
5 changed files with 62 additions and 2 deletions
|
@ -5,9 +5,14 @@
|
||||||
:dataUrl="dataSource"
|
:dataUrl="dataSource"
|
||||||
:reloadingTable="reloadingTable"
|
:reloadingTable="reloadingTable"
|
||||||
:toolbarActions="toolbarActions"
|
:toolbarActions="toolbarActions"
|
||||||
|
:activePageUrl="activePageUrl"
|
||||||
|
:archivedPageUrl="archivedPageUrl"
|
||||||
|
:currentViewMode="currentViewMode"
|
||||||
:actionsUrl="actionsUrl"
|
:actionsUrl="actionsUrl"
|
||||||
@tableReloaded="reloadingTable = false"
|
@tableReloaded="reloadingTable = false"
|
||||||
@create="createForm"
|
@create="createForm"
|
||||||
|
@archive="archive"
|
||||||
|
@restore="restore"
|
||||||
@access="access"
|
@access="access"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -52,7 +57,10 @@ export default {
|
||||||
userRolesUrl: {
|
userRolesUrl: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
}
|
},
|
||||||
|
activePageUrl: { type: String },
|
||||||
|
archivedPageUrl: { type: String },
|
||||||
|
currentViewMode: { type: String, required: true }
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -129,6 +137,22 @@ export default {
|
||||||
object: rows[0],
|
object: rows[0],
|
||||||
roles_path: this.userRolesUrl
|
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
|
def fetch_records
|
||||||
@records = Form.where(team: @team).readable_by_user(@user)
|
@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
|
end
|
||||||
|
|
||||||
def filter_records; end
|
def filter_records; end
|
||||||
|
|
|
@ -18,7 +18,9 @@ module Toolbars
|
||||||
return [] if @forms.none?
|
return [] if @forms.none?
|
||||||
|
|
||||||
[
|
[
|
||||||
access_action
|
access_action,
|
||||||
|
archive_action,
|
||||||
|
restore_action
|
||||||
].compact
|
].compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,5 +36,29 @@ module Toolbars
|
||||||
type: :emit
|
type: :emit
|
||||||
}
|
}
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
data-source="<%= forms_path(format: :json) %>"
|
data-source="<%= forms_path(format: :json) %>"
|
||||||
create-url="<%= forms_path %>"
|
create-url="<%= forms_path %>"
|
||||||
user-roles-url="<%= user_roles_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>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1075,6 +1075,8 @@ en:
|
||||||
toolbar:
|
toolbar:
|
||||||
new: 'New form'
|
new: 'New form'
|
||||||
access: 'Access'
|
access: 'Access'
|
||||||
|
archive: 'Archive'
|
||||||
|
restore: 'Restore'
|
||||||
table:
|
table:
|
||||||
name: 'Form name'
|
name: 'Form name'
|
||||||
code: 'ID'
|
code: 'ID'
|
||||||
|
|
Loading…
Add table
Reference in a new issue