File tree Expand file tree Collapse file tree 2 files changed +30
-13
lines changed Expand file tree Collapse file tree 2 files changed +30
-13
lines changed Original file line number Diff line number Diff line change 2828 :exclude-file-ids =" excludeFileIds"
2929 />
3030 </div >
31- <div class =" form-row mt-2 mb-3" >
31+ <div v-if = " showApplyButton " class =" form-row mt-2 mb-3" >
3232 <button class =" btn btn-primary btn-sm" @click =" applySelection" >
3333 {{ applyButtonText }}
3434 </button >
@@ -81,6 +81,10 @@ export default {
8181 type: Boolean ,
8282 default: false ,
8383 },
84+ showApplyButton: {
85+ type: Boolean ,
86+ default: true ,
87+ },
8488 },
8589 emits: [" update:modelValue" , " apply" ],
8690 data () {
@@ -90,8 +94,24 @@ export default {
9094 };
9195 },
9296 watch: {
93- modelValue (newVal ) {
94- this .internalFileModel = newVal .slice ();
97+ modelValue: {
98+ handler (newVal ) {
99+ // Avoid triggering the internalFileModel watcher when syncing from parent
100+ if (JSON .stringify (newVal) !== JSON .stringify (this .internalFileModel )) {
101+ this .internalFileModel = newVal .slice ();
102+ }
103+ },
104+ deep: true ,
105+ },
106+ internalFileModel: {
107+ handler (newVal , oldVal ) {
108+ // Emit changes immediately when showApplyButton is false
109+ // Only emit if the value actually changed
110+ if (! this .showApplyButton && JSON .stringify (newVal) !== JSON .stringify (oldVal)) {
111+ this .$emit (" update:modelValue" , newVal .slice ());
112+ }
113+ },
114+ deep: true ,
95115 },
96116 },
97117 mounted () {
Original file line number Diff line number Diff line change 3131 @update:modelValue =" onFileSelectionChange"
3232 />
3333 </div >
34- <div class =" form-row mt-2" >
35- <button class =" btn btn-primary btn-sm" @click =" applyFileSelection" >Apply Selection</button >
36- </div >
3734 <CollapsibleComparisonFileSelect
3835 v-model =" comparisonFileModel"
3936 :item_id =" item_id"
4037 :block_id =" block_id"
4138 :extensions =" blockInfo.attributes.accepted_file_extensions"
4239 :exclude-file-ids =" file_ids"
4340 :initially-expanded =" comparisonFileModel.length > 0"
44- @ apply= " applyComparisonFiles "
41+ :show- apply-button = " false "
4542 />
43+ <div class =" form-row mt-2" >
44+ <button class =" btn btn-primary btn-sm" @click =" applyAllSelections" >Apply Changes</button >
45+ </div >
4646 <div >
4747 <div class =" form-row" >
4848 <div class =" input-group form-inline" >
@@ -452,14 +452,11 @@ export default {
452452 },
453453
454454 /**
455- * Apply the currently staged file selection
456- * Used by the "Apply Selection " button
455+ * Apply all pending changes ( file selection and comparison files)
456+ * Used by the consolidated "Apply Changes " button
457457 */
458- applyFileSelection () {
458+ applyAllSelections () {
459459 this .updateFileIds ();
460- this .updateBlock ();
461- },
462- applyComparisonFiles () {
463460 this .comparison_file_ids = this .pending_comparison_file_ids .slice ();
464461 this .updateBlock ();
465462 },
You can’t perform that action at this time.
0 commit comments