Skip to content

Commit

Permalink
sh_reception_packaging_dimension_mobile: refactor for extensibility
Browse files Browse the repository at this point in the history
  • Loading branch information
TDu committed Oct 31, 2023
1 parent 0271954 commit 1d73bae
Showing 1 changed file with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@

import {process_registry} from "/shopfloor_mobile_base/static/wms/src/services/process_registry.js";

import {reception_states} from "/shopfloor_reception_mobile/static/src/scenario/reception_states.js";

// Get the original template of the reception scenario
const reception_scenario = process_registry.get("reception");
const _get_states = reception_scenario.component.methods._get_states;
// Get the original template of the reception scenario
const template = reception_scenario.component.template;
// And inject the new state template (for this module) into it
const pos = template.indexOf("</Screen>");

const new_template =
template.substring(0, pos) +
`
Expand Down Expand Up @@ -77,7 +75,7 @@ const new_template =
v-model="state.data.packaging.max_weight"
></v-text-field>
</v-row>
<!-- extend -->
</v-container>
</v-form>
Expand Down Expand Up @@ -105,8 +103,11 @@ const new_template =
// - the js code for the new state
const ReceptionPackageDimension = process_registry.extend("reception", {
template: new_template,
"methods.get_packaging_measurements": function () {
return ["length", "width", "height", "max_weight", "qty", "barcode"];
},
"methods._get_states": function () {
let states = reception_states.bind(this)();
let states = _get_states.bind(this)();
states["set_packaging_dimension"] = {
display_info: {
title: "Set packaging dimension",
Expand All @@ -120,15 +121,7 @@ const ReceptionPackageDimension = process_registry.extend("reception", {
selected_line_id: this.state.data.selected_move_line.id,
packaging_id: this.state.data.packaging.id,
};
const measurements = [
"length",
"width",
"height",
"max_weight",
"qty",
"barcode",
];
for (const measurement of measurements) {
for (const measurement of this.get_packaging_measurements()) {
values[measurement] = this.state.data.packaging[measurement];
}
return values;
Expand Down

0 comments on commit 1d73bae

Please sign in to comment.