This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
<v-col cols="12">
|
||||
<gz-pick-list
|
||||
v-if="!formState.readOnly"
|
||||
v-model="selectedPart"
|
||||
:ayaType="ayaTypes().Part"
|
||||
:showEditIcon="true"
|
||||
:label="$ay.t('Part')"
|
||||
@@ -39,7 +40,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<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>
|
||||
<v-icon small @click="removeItem(item)">
|
||||
@@ -201,67 +202,17 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||
/*
|
||||
{
|
||||
"data": {
|
||||
"id": 2,
|
||||
"concurrency": 4644405,
|
||||
"name": "asm2662",
|
||||
"active": true,
|
||||
"notes": "Vel error explicabo facilis nemo.",
|
||||
"wiki": null,
|
||||
"customFields": null,
|
||||
"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: []
|
||||
},
|
||||
obj: {
|
||||
id: 0,
|
||||
concurrency: 0,
|
||||
name: null,
|
||||
active: true,
|
||||
notes: null,
|
||||
wiki: null,
|
||||
customFields: "{}",
|
||||
tags: [],
|
||||
items: []
|
||||
},
|
||||
formState: {
|
||||
ready: false,
|
||||
dirty: false,
|
||||
@@ -311,11 +262,22 @@ export default {
|
||||
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: {
|
||||
addItem: function() {
|
||||
let vm = this;
|
||||
let selected = vm.$refs.partId.getFullSelectionValue();
|
||||
if (selected == null) {
|
||||
if (selected == null || selected.id == null) {
|
||||
return;
|
||||
}
|
||||
let index = vm.obj.items.findIndex(z => z.partId == selected.id);
|
||||
@@ -329,6 +291,8 @@ export default {
|
||||
partId: selected.id,
|
||||
partDisplay: selected.name
|
||||
});
|
||||
|
||||
vm.formState.dirty = true;
|
||||
},
|
||||
removeItem: function(item) {
|
||||
let vm = this;
|
||||
|
||||
Reference in New Issue
Block a user