mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-25 01:04:02 +08:00
Improve error handling for label printing [SCI-10039] (#6997)
This commit is contained in:
parent
edce20e303
commit
9d48cbbb86
4 changed files with 17 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable no-param-reassign */
|
||||
/* eslint-disable no-undef */
|
||||
/* global I18n */
|
||||
/* global HelperModule I18n */
|
||||
/* eslint-disable no-unused-vars, no-use-before-define */
|
||||
|
||||
/* config = {
|
||||
|
@ -218,6 +218,8 @@ var zebraPrint = (function() {
|
|||
updateProgressModalData(progressModal, printData.printer_name, PRINTER_STATUS_ERROR, PRINTER_STATUS_ERROR);
|
||||
}
|
||||
});
|
||||
}).fail(() => {
|
||||
HelperModule.flashAlertMsg(I18n.t('repository_row.modal_print_label.general_error'), 'danger');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -91,6 +91,8 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
/* global HelperModule */
|
||||
|
||||
import DropdownSelector from '../shared/dropdown_selector.vue';
|
||||
import LabelPreview from '../label_template/components/label_preview.vue';
|
||||
|
||||
|
@ -203,8 +205,14 @@ export default {
|
|||
this.labelTemplateError = null;
|
||||
this.labelTemplateCode = result.label_code;
|
||||
}).fail((result) => {
|
||||
this.labelTemplateError = result.responseJSON.error;
|
||||
this.labelTemplateCode = result.responseJSON.label_code;
|
||||
if (result.responseJSON) {
|
||||
this.labelTemplateError = result.responseJSON.error;
|
||||
this.labelTemplateCode = result.responseJSON.label_code;
|
||||
} else {
|
||||
this.labelTemplateError = null;
|
||||
this.labelTemplateCode = null;
|
||||
HelperModule.flashAlertMsg(this.i18n.t('repository_row.modal_print_label.general_error'), 'danger');
|
||||
}
|
||||
});
|
||||
},
|
||||
submitPrint() {
|
||||
|
@ -233,6 +241,8 @@ export default {
|
|||
$(this.$refs.modal).modal('hide');
|
||||
this.$emit('close');
|
||||
PrintProgressModal.init(data);
|
||||
}).fail(() => {
|
||||
HelperModule.flashAlertMsg(this.i18n.t('repository_row.modal_print_label.general_error'), 'danger');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ module LabelTemplates
|
|||
errors = []
|
||||
keys = @label_template.content.scan(/(?<=\{\{).*?(?=\}\})/).uniq
|
||||
label = keys.reduce(@label_template.content.dup) do |rendered_content, key|
|
||||
rendered_content.gsub!(/\{\{#{key}\}\}/, fetch_value(key))
|
||||
rendered_content.gsub!(Regexp.new(Regexp.escape("{{#{key}}}")), fetch_value(key))
|
||||
rescue LabelTemplates::ColumnNotFoundError,
|
||||
LabelTemplates::LogoNotFoundError,
|
||||
LabelTemplates::LogoParamsError => e
|
||||
|
|
|
@ -2584,6 +2584,7 @@ en:
|
|||
title: "There seems to be no printer available"
|
||||
description: "To learn more about printing labels and label printers please visit our blog."
|
||||
visit_blog: "Visit blog"
|
||||
general_error: "Something went wrong"
|
||||
reminder:
|
||||
clear: "Clear"
|
||||
low_stock_title: "Item running low"
|
||||
|
|
Loading…
Reference in a new issue