mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-02 01:45:38 +08:00
Merge pull request #4539 from aignatov-bio/ai-sci-7340-save-label-dimenssions-on-preview-button
Save dimensions on refresh label template preview [SCI-7340]
This commit is contained in:
commit
83c3699493
1 changed files with 28 additions and 7 deletions
|
@ -174,7 +174,7 @@
|
||||||
this.previewContent = this.labelTemplate.attributes.content
|
this.previewContent = this.labelTemplate.attributes.content
|
||||||
this.newLabelWidth = this.labelTemplate.attributes.width_mm
|
this.newLabelWidth = this.labelTemplate.attributes.width_mm
|
||||||
this.newLabelHeight = this.labelTemplate.attributes.height_mm
|
this.newLabelHeight = this.labelTemplate.attributes.height_mm
|
||||||
this.newLabelDensity = this.labelTemplate.attributes.newDensity
|
this.newLabelDensity = this.labelTemplate.attributes.density
|
||||||
this.newLabelUnit = this.labelTemplate.attributes.unit
|
this.newLabelUnit = this.labelTemplate.attributes.unit
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -227,6 +227,8 @@
|
||||||
updateContent() {
|
updateContent() {
|
||||||
this.previewValid = true;
|
this.previewValid = true;
|
||||||
|
|
||||||
|
this.saveLabelDimensions();
|
||||||
|
|
||||||
if (!this.editingContent) return;
|
if (!this.editingContent) return;
|
||||||
|
|
||||||
if (this.skipSave) {
|
if (this.skipSave) {
|
||||||
|
@ -242,20 +244,39 @@
|
||||||
type: 'PATCH',
|
type: 'PATCH',
|
||||||
data: {label_template: {
|
data: {label_template: {
|
||||||
content: this.newContent,
|
content: this.newContent,
|
||||||
width_mm: this.newLabelWidth,
|
|
||||||
height_mm: this.newLabelHeight,
|
|
||||||
density: this.newLabelDensity,
|
|
||||||
unit: this.newLabelUnit
|
|
||||||
}},
|
}},
|
||||||
success: (result) => {
|
success: (result) => {
|
||||||
this.labelTemplate.attributes.content = result.data.attributes.content;
|
this.labelTemplate.attributes.content = result.data.attributes.content;
|
||||||
this.labelTemplate.attributes.width_mm = result.data.attributes.width_mm;
|
|
||||||
this.labelTemplate.attributes.height_mm = result.data.attributes.height_mm;
|
|
||||||
this.editingContent = false;
|
this.editingContent = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
saveLabelDimensions() {
|
||||||
|
if (this.newLabelWidth == this.labelTemplate.attributes.width_mm &&
|
||||||
|
this.newLabelHeight == this.labelTemplate.attributes.height_mm &&
|
||||||
|
this.newLabelDensity == this.labelTemplate.attributes.density &&
|
||||||
|
this.newLabelUnit == this.labelTemplate.attributes.unit) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: this.labelTemplate.attributes.urls.update,
|
||||||
|
type: 'PATCH',
|
||||||
|
data: {label_template: {
|
||||||
|
width_mm: this.newLabelWidth,
|
||||||
|
height_mm: this.newLabelHeight,
|
||||||
|
density: this.newLabelDensity,
|
||||||
|
unit: this.newLabelUnit
|
||||||
|
}},
|
||||||
|
success: (result) => {
|
||||||
|
this.labelTemplate.attributes.width_mm = result.data.attributes.width_mm;
|
||||||
|
this.labelTemplate.attributes.height_mm = result.data.attributes.height_mm;
|
||||||
|
this.labelTemplate.attributes.density = result.data.attributes.density;
|
||||||
|
this.labelTemplate.attributes.unit = result.data.attributes.unit;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
generatePreview(skipSave = false) {
|
generatePreview(skipSave = false) {
|
||||||
this.skipSave = skipSave;
|
this.skipSave = skipSave;
|
||||||
if (!skipSave && this.previewContent === this.newContent && this.previewValid) {
|
if (!skipSave && this.previewContent === this.newContent && this.previewValid) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue