Add edit button to label templates and fix last updated by [SCI-8373] (#5376)

This commit is contained in:
ajugo 2023-05-08 11:27:29 +02:00 committed by GitHub
parent a337b98ed5
commit 783d5d03ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 3 deletions

View file

@ -38,8 +38,7 @@
function renderNameHTML(data, type, row) {
return `${data.icon_image_tag}<a
href='${row.DT_RowAttr['data-edit-url']}'
class='record-info-link'
onclick='window.location.href = this.href; return false;'
class='label-info-link'
>${data.name}</a>`;
}
@ -79,6 +78,14 @@
});
}
function initEditButton() {
$('#editTemplate').on('click', function() {
if (rowsSelected.length === 1) {
window.location.href = rowsSelected[0].editUrl;
}
});
}
function initDuplicateButton() {
$('#duplicateLabelTemplate').on('click', function() {
if (rowsSelected.length > 0) {
@ -138,6 +145,7 @@
$('.fluics-warning').addClass('hidden');
$('.selected-actions').removeClass('hidden');
$('.nonselected-actions').addClass('hidden');
$('.selected-one-actions').toggleClass('hidden', (rowsSelected.length > 1));
if (labelFormats() === 'ZPL') {
$('#deleteLabelTemplate').toggleClass('hidden', defaultSelected());
$('#setZplDefaultLabelTemplate').toggleClass('hidden', (rowsSelected.length > 1 || defaultSelected()));
@ -149,6 +157,7 @@
$('#setFluicsDefaultLabelTemplate').toggleClass('hidden', (rowsSelected.length > 1 || defaultSelected()));
$('.fluics-warning').removeClass('hidden');
} else {
$('.selected-one-actions').addClass('hidden');
$('.fluics-warning').removeClass('hidden');
$('.selected-actions').addClass('hidden');
}
@ -281,6 +290,7 @@
let toolBar = $($('#labelTemplatesToolbar').html());
$('.label-buttons-container').html(toolBar);
initCreateButton();
initEditButton();
initSetDefaultButton();
initDuplicateButton();
initDeleteModal();

View file

@ -63,7 +63,8 @@ class LabelTemplatesController < ApplicationController
def update
@label_template.transaction do
@label_template.update!(label_template_params)
update_label_template_params = label_template_params.merge(last_modified_by_id: current_user.id)
@label_template.update!(update_label_template_params)
log_activity(:label_template_edited, @label_template)
end
render json: @label_template, serializer: LabelTemplateSerializer, user: current_user

View file

@ -10,6 +10,10 @@
<%= image_tag 'label_template_icons/fluics_update.svg' %>
<span class="button-text"><%= t('label_templates.index.toolbar.check_for_updates') %></span>
</button>
<div class="btn btn-light hidden selected-one-actions auto-shrink-button" id="editTemplate" title="<%= t('label_templates.index.toolbar.edit_template') %>">
<i class="fas fa-pencil-alt"></i>
<span class="button-text"><%= t('label_templates.index.toolbar.edit_template') %></span>
</div>
<div class="btn btn-light hidden selected-actions auto-shrink-button"
title="<%= t('label_templates.index.toolbar.duplicate') %>"
data-url="<%= duplicate_label_templates_path %>"

View file

@ -911,6 +911,7 @@ en:
set_zpl_default: 'Set as default ZPL label'
set_fluics_default: 'Set as default Fluics label'
fluics_warning: 'Built-in FLUICS templates cant be edited, deleted or duplicated'
edit_template: 'Edit'
delete_modal:
title: 'Delete Label template(s)'
description: 'Are you sure you want to delete the selected label template(s)?'