Skip to content

Commit b5c587b

Browse files
committed
[Ui] Fix hasFieldsError reactivity + add events on fileupload component
1 parent 95e70d8 commit b5c587b

File tree

7 files changed

+490
-484
lines changed

7 files changed

+490
-484
lines changed

vertigo-ui-vuejs/src/components/VFileUpload.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default {
6060
callbackOnDelete: { default : false },
6161
inputProps: { type: Object }
6262
},
63-
emits: ["update:file-info-uris", "download-file", "file-ok", "file-failed"],
63+
emits: ["update:file-info-uris", "download-file", "file-ok", "file-failed", "init-ok", "init-ko"],
6464
computed: {
6565
6666
},
@@ -78,8 +78,11 @@ export default {
7878
this.files = uiFileInfos.map((uiFileInfo) => {
7979
return {...uiFileInfo, status: "OK"};
8080
})
81+
this.$emit('init-ok');
8182
}.bind(this))
8283
.catch(function (error) { //Ko
84+
this.$emit('update:file-info-uris', []); // reset
85+
this.$emit('init-ko');
8386
if (this.$q) {
8487
if(error.response) {
8588
this.$q.notify(error.response.status + ":" + error.response.statusText + " Can't load file "+xhrParams);

vertigo-ui-vuejs/src/components/VFileUploadQuasar.vue

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default {
109109
downloadUrl : { type : String, default : (props) => props.baseUrl + '/download'},
110110
multiple: { type : Boolean, default : true }
111111
},
112-
emits: ["update:file-info-uris", "download-file"],
112+
emits: ["update:file-info-uris", "download-file", "init-ok", "init-ko"],
113113
computed: {
114114
115115
},
@@ -127,8 +127,11 @@ export default {
127127
this.files = uiFileInfos.map((uiFileInfo) => {
128128
return uiFileInfo;
129129
})
130+
this.$emit('init-ok');
130131
}.bind(this))
131132
.catch(function (error) { //Ko
133+
this.$emit('update:file-info-uris', []); // reset
134+
this.$emit('init-ko');
132135
if(error.response) {
133136
this.$q.notify(error.response.status + ":" + error.response.statusText + " Can't load file "+xhrParams);
134137
} else {
@@ -174,21 +177,21 @@ export default {
174177
var newFileInforUris = [...this.fileInfoUris];
175178
var xhrParams = {};
176179
xhrParams[this.fieldName] = removedFile.fileUri;
177-
this.$http.delete(this.url, { params: xhrParams, credentials: false })
178-
.then(function (/*response*/) { //Ok
179-
if (this.multiple) {
180-
this.files.splice(indexOfFile, 1)
181-
newFileInforUris.splice(indexOfFile, 1);
182-
} else {
183-
this.files.splice(0);
184-
newFileInforUris.splice(0);
185-
}
186-
this.$emit('update:file-info-uris', newFileInforUris);
187-
//this.uploader_forceComputeUploadedSize(componentId);
188-
}.bind(this))
189-
.catch(function (error) { //Ko
190-
this.$q.notify(error.response.status + ":" + error.response.statusText + " Can't remove temporary file");
191-
}.bind(this));
180+
this.$http.delete(this.url, { params: xhrParams, credentials: false })
181+
.then(function (/*response*/) { //Ok
182+
if (this.multiple) {
183+
this.files.splice(indexOfFile, 1)
184+
newFileInforUris.splice(indexOfFile, 1);
185+
} else {
186+
this.files.splice(0);
187+
newFileInforUris.splice(0);
188+
}
189+
this.$emit('update:file-info-uris', newFileInforUris);
190+
//this.uploader_forceComputeUploadedSize(componentId);
191+
}.bind(this))
192+
.catch(function (error) { //Ko
193+
this.$q.notify(error.response.status + ":" + error.response.statusText + " Can't remove temporary file");
194+
}.bind(this));
192195
193196
},
194197
globalCanAddFiles(quasarFiles) {

vertigo-ui-vuejs/src/methods.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ export default {
9292
return notifyMessages;
9393
}
9494
},
95-
96-
i18n: function() {
97-
return VertigoUi.lang[VertigoUi.vuiLang];
98-
},
99-
95+
96+
i18n: function() {
97+
return VertigoUi.lang[VertigoUi.vuiLang];
98+
},
99+
100100
getSafeValue: function (objectkey, fieldKey, subFieldKey) {
101101
if (this.$data.vueData[objectkey] && this.$data.vueData[objectkey][fieldKey]) {
102102
return this.$data.vueData[objectkey][fieldKey][subFieldKey];
@@ -546,8 +546,7 @@ export default {
546546
const fieldName = field.split("_")[0]; // trim any qualifier like "_fmt"
547547
if (fieldsErrors) {
548548
var objectName = rowIndex != null ? object + '[' + rowIndex + ']' : object;
549-
return Object.prototype.hasOwnProperty.call(fieldsErrors, objectName) &&
550-
fieldsErrors[objectName] && Object.prototype.hasOwnProperty.call(fieldsErrors[objectName], fieldName) && fieldsErrors[objectName][fieldName].length > 0
549+
return fieldsErrors?.[objectName]?.[fieldName]?.length > 0;
551550
}
552551
return false;
553552
},

0 commit comments

Comments
 (0)