22 <v-slide-x-reverse-transition mode =" out-in" >
33 <div class =" d-flex align-center justify-space-between" :key =" `${fieldName}_${unlocked}_${itemId}`" >
44 <slot v-if =" !unlocked" >
5- <div class =" d-flex align-baseline justify-start" >
6- <h4 class =" my-0 mr-2" >
7- {{ fieldLabel }}
8- </h4 >
5+ <div class =" d-flex align-baseline justify-end" >
6+ <h4 class =" my-0 mr-2" >{{ fieldLabel }}</h4 >
97 <h3 class =" white--text textShadow my-0" >
108 <div v-if =" itemValue" >
119 {{ itemValue | currency }}
1917
2018 <slot name =" editField" v-if =" unlocked" class =" w-100" >
2119 <div id =" editFieldSlot" class =" w-100" >
22- <EditDialog
23- v-if =" itemValue"
24- dialogColor =" grey darken-3"
25- persistent
26- large
27- @save =" saveChanges(itemId, fieldName, editValue, editValue, locationId)"
28- @cancel =" editValue = itemValue"
29- >
30- <div class =" d-flex align-center justify-end w-100" id =" editFieldWrapper" >
31- <h4 class =" my-0 mr-2" >
32- {{ fieldLabel }}
33- </h4 >
20+ <div class =" d-flex" v-if =" itemValue" >
21+ <EditDialog
22+ v-if =" itemValue"
23+ dialogColor =" grey darken-3"
24+ persistent
25+ large
26+ @save =" saveChanges(itemId, fieldName, editValue, editValue, locationId)"
27+ @cancel =" editValue = itemValue"
28+ >
29+ <div class =" d-flex align-center justify-end w-100" id =" editFieldWrapper" >
30+ <h4 class =" my-0 mr-2" >{{ fieldLabel }}</h4 >
3431
35- <v-text-field
36- dense
37- hide-details
38- :value =" itemValue"
39- :id =" fieldId"
40- :name =" fieldName"
41- :label =" fieldLabel"
42- :hint =" fieldHint"
43- filled
44- :full-width =" true"
45- disabled
46- background-color =" grey darken-3"
47- >
48- <template v-slot :append-outer >
49- <v-btn color =" primary" >
50- <v-icon small >fa fa-edit</v-icon >
51- </v-btn >
52- </template >
53- </v-text-field >
54- </div >
55-
56- <template v-slot :input >
57- <div class =" itemTextFieldInputSlot" >
58- <h3 class =" my-1 textShadow" >Edit {{ fieldLabel }}</h3 >
5932 <v-text-field
60- autocomplete =" off"
61- autofocus
62- :full-width =" true"
63- filled
64- background-color =" grey darken-4"
65- counter
33+ dense
34+ hide-details
35+ :value =" itemValue"
36+ :id =" fieldId"
37+ :name =" fieldName"
6638 :label =" fieldLabel"
67- v-model =" editValue"
68- :rules =" rules"
69- @update:error =" handleError"
70- />
39+ :hint =" fieldHint"
40+ filled
41+ :full-width =" true"
42+ disabled
43+ background-color =" grey darken-3"
44+ >
45+ <template v-slot :append-outer >
46+ <v-btn color =" primary" >
47+ <v-icon small >fa fa-edit</v-icon >
48+ </v-btn >
49+ </template >
50+ </v-text-field >
7151 </div >
72- </template >
73- </EditDialog >
52+
53+ <template v-slot :input >
54+ <div class =" itemTextFieldInputSlot" >
55+ <div class =" d-flex-column w-100 align-start justify-start" >
56+ <div class =" d-flex flex-grow-1" >
57+ <h3 class =" my-1 textShadow" >Edit {{ fieldLabel }}</h3 >
58+ </div >
59+ <div class =" d-flex" >
60+ <v-text-field
61+ autocomplete =" off"
62+ autofocus
63+ :full-width =" true"
64+ filled
65+ background-color =" grey darken-4"
66+ counter
67+ :label =" fieldLabel"
68+ v-model =" editValue"
69+ :rules =" rules"
70+ @update:error =" handleError"
71+ />
72+ </div >
73+ </div >
74+ </div >
75+ </template >
76+ </EditDialog >
77+
78+ <div class =" d-flex justify-center align-center" >
79+ <v-btn
80+ class =" textShadow ml-5"
81+ color =" error"
82+ v-if =" includeDeleteButton"
83+ @click =" deletePrice(itemPriceId)"
84+ style =" min-width :20px ;"
85+ >
86+ <v-icon small class =" " >fa fa-times-circle</v-icon >
87+ </v-btn >
88+ </div >
89+ </div >
7490
7591 <div v-else class =" " >
7692 <h3 class =" white--text textShadow my-0" >
84100</template >
85101
86102<script >
87- import { UPDATE_PRICE_SELECTED_LINNWORKS_ITEM } from " @/store/action-types.js" ;
103+ import { UPDATE_PRICE_SELECTED_LINNWORKS_ITEM , DELETE_DECLINE_PRICE_SELECTED_LINNWORKS_ITEM } from " @/store/action-types.js" ;
88104import EditDialog from " ../EditDialog" ;
89105
90106export default {
@@ -97,7 +113,9 @@ export default {
97113 fieldId: { type: [String ] },
98114 fieldLabel: { type: [String ] },
99115 fieldHint: { type: [String ] },
100- rules: { type: [Array ] }
116+ rules: { type: [Array ] },
117+ includeDeleteButton: { type: [Boolean ], default: false },
118+ itemPriceId: { type: [String , Boolean ], default: false }
101119 },
102120 components: {
103121 EditDialog
@@ -139,6 +157,30 @@ export default {
139157 }
140158 if (! result && error) this .$toastr .e (` ${ field} not updated!` , error);
141159 }
160+ },
161+ async deletePrice (inventoryItemPriceId ) {
162+ const confirm = await this .$confirm (
163+ ` <h3 class="text-center py-3">Delete this ${ this .fieldLabel } ?</h3>
164+ <p>This will remove the ${ this .fieldLabel } . You cannot undo this operation. Are you sure you want to delete it?</p>` ,
165+ { title: ` Delete this ${ this .fieldLabel } ?` }
166+ );
167+ if (confirm) this .callDeletePrice (inventoryItemPriceId);
168+ },
169+ async callDeletePrice (inventoryItemPriceId ) {
170+ const pkStockItemID = this .itemId ;
171+ const resp = await this .$store .dispatch (
172+ ` linnworks/inventory/selectedItem/${ DELETE_DECLINE_PRICE_SELECTED_LINNWORKS_ITEM } ` ,
173+ { inventoryItemPriceId, pkStockItemID }
174+ );
175+
176+ const { result , error } = resp;
177+ if (result) {
178+ this .$toastr .defaultTimeout = 1500 ;
179+ this .$toastr .s (` ${ this .fieldLabel } update success!` , result);
180+ this .$emit (" update:itemValue" , " 0.00" );
181+ this .$emit (" hasChanges" , true );
182+ }
183+ if (! result && error) this .$toastr .e (` ${ this .fieldLabel } not updated!` , error);
142184 }
143185 }
144186};
0 commit comments