This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
<gz-pick-list
|
<gz-pick-list
|
||||||
v-if="!formState.readOnly"
|
v-if="!formState.readOnly"
|
||||||
|
v-model="selectedPart"
|
||||||
:ayaType="ayaTypes().Part"
|
:ayaType="ayaTypes().Part"
|
||||||
:showEditIcon="true"
|
:showEditIcon="true"
|
||||||
:label="$ay.t('Part')"
|
:label="$ay.t('Part')"
|
||||||
@@ -39,7 +40,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="item in obj.items" :key="item.partId">
|
<tr v-for="item in sortedList" :key="item.partId">
|
||||||
<td>{{ item.partDisplay }}</td>
|
<td>{{ item.partDisplay }}</td>
|
||||||
<td>
|
<td>
|
||||||
<v-icon small @click="removeItem(item)">
|
<v-icon small @click="removeItem(item)">
|
||||||
@@ -201,67 +202,17 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||||
/*
|
obj: {
|
||||||
{
|
id: 0,
|
||||||
"data": {
|
concurrency: 0,
|
||||||
"id": 2,
|
name: null,
|
||||||
"concurrency": 4644405,
|
active: true,
|
||||||
"name": "asm2662",
|
notes: null,
|
||||||
"active": true,
|
wiki: null,
|
||||||
"notes": "Vel error explicabo facilis nemo.",
|
customFields: "{}",
|
||||||
"wiki": null,
|
tags: [],
|
||||||
"customFields": null,
|
items: []
|
||||||
"tags": [
|
},
|
||||||
"silver",
|
|
||||||
"white",
|
|
||||||
"xanthic",
|
|
||||||
"zone2",
|
|
||||||
"zone5"
|
|
||||||
],
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"id": 5,
|
|
||||||
"concurrency": 4644405,
|
|
||||||
"partAssemblyId": 2,
|
|
||||||
"partId": 319
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 6,
|
|
||||||
"concurrency": 4644405,
|
|
||||||
"partAssemblyId": 2,
|
|
||||||
"partId": 25
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 7,
|
|
||||||
"concurrency": 4644405,
|
|
||||||
"partAssemblyId": 2,
|
|
||||||
"partId": 267
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 8,
|
|
||||||
"concurrency": 4644405,
|
|
||||||
"partAssemblyId": 2,
|
|
||||||
"partId": 213
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
obj:
|
|
||||||
//IMPORTANT NOTE: Fields that are NON NULLABLE in the schema for the table but *are* hideable **MUST** have a default value set here or else there will be no way to save the record
|
|
||||||
//I.E. Serial, usertype fields, ACTIVE
|
|
||||||
//Also, if it's a non-nullable Enum backed field then it should have a valid selection i.e. not zero if there is no zero
|
|
||||||
{
|
|
||||||
id: 0,
|
|
||||||
concurrency: 0,
|
|
||||||
name: null,
|
|
||||||
active: true,
|
|
||||||
notes: null,
|
|
||||||
wiki: null,
|
|
||||||
customFields: "{}",
|
|
||||||
tags: [],
|
|
||||||
items: []
|
|
||||||
},
|
|
||||||
formState: {
|
formState: {
|
||||||
ready: false,
|
ready: false,
|
||||||
dirty: false,
|
dirty: false,
|
||||||
@@ -311,11 +262,22 @@ export default {
|
|||||||
deep: true
|
deep: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
sortedList: function() {
|
||||||
|
function compare(a, b) {
|
||||||
|
if (a.partDisplay < b.partDisplay) return -1;
|
||||||
|
if (a.partDisplay > b.partDisplay) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.obj.items.slice().sort(compare);
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addItem: function() {
|
addItem: function() {
|
||||||
let vm = this;
|
let vm = this;
|
||||||
let selected = vm.$refs.partId.getFullSelectionValue();
|
let selected = vm.$refs.partId.getFullSelectionValue();
|
||||||
if (selected == null) {
|
if (selected == null || selected.id == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let index = vm.obj.items.findIndex(z => z.partId == selected.id);
|
let index = vm.obj.items.findIndex(z => z.partId == selected.id);
|
||||||
@@ -329,6 +291,8 @@ export default {
|
|||||||
partId: selected.id,
|
partId: selected.id,
|
||||||
partDisplay: selected.name
|
partDisplay: selected.name
|
||||||
});
|
});
|
||||||
|
|
||||||
|
vm.formState.dirty = true;
|
||||||
},
|
},
|
||||||
removeItem: function(item) {
|
removeItem: function(item) {
|
||||||
let vm = this;
|
let vm = this;
|
||||||
|
|||||||
Reference in New Issue
Block a user