Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function match(pattern, path) {
return path.match(new RegExp(`^${pattern.replace(/\//g, '\\/').replace(/\*\*/g, '(\\/[^\\/]+)*').replace(/\*/g, '[^\\/]+').replace(/((?!\\))\?/g, '$1.')}$`, 'i'));
}
if (uiKitUpload.allow && !match(uiKitUpload.allow, file.name)) {
uiKitUpload.fail(uiKitUpload.msgInvalidName.replace('%s', uiKitUpload.allow));
return;
}
let data = new FormData();
data.append('pre_sign_form[filename]', file.name);
data.append('pre_sign_form[field]', this.fieldPath);
data.append('pre_sign_form[_token]', this.uploadSignCsrfToken);
UIkit.util.ajax(this.uploadSignUrl, {
method: 'POST',
data: data,
headers: { "Authentication-Fallback": true }
}).then((result) => {
// Temporary save the parameter of this file. If upload is successful, we save them to the component.
let preSignedUrl = JSON.parse(result.responseText);
uiKitUpload.url = preSignedUrl.pre_signed_url;
this.tmpId = preSignedUrl.uuid;
this.tmpFileSize = file.size;
this.tmpFileType = file.type;
this.tmpFileName = preSignedUrl.filename;
this.tmpChecksum = preSignedUrl.checksum;
let headers = {};
if (this.acl) {
moved(event) {
if(this.isSortable) {
this.$emit('updateRow', {
id: event.detail[1].dataset.id,
data: {
position: UIkit.util.index(event.detail[1])
}
});
}
},
renderField(field, identifier, meta = false) {
moved(event) {
if(this.isSortable) {
let data = {};
data[this.sort.field] = UIkit.util.index(event.detail[1]);
this.$emit('updateRow', {
id: event.detail[1].dataset.id,
data: data
});
}
}
},
moved(event) {
if(this.isSortable) {
let data = {};
data[this.sort.field] = UIkit.util.index(event.detail[1]);
this.$emit('updateRow', {
id: event.detail[1].dataset.id,
data: data
});
}
}
},
mounted() {
UIkit.modal(this.$refs.modal).show();
UIkit.util.on(this.$refs.modal, 'hide', (e) => {
if(e.target === this.$refs.modal) {
this.$emit('hide');
}
});
},
beforeDestroy() {
mounted() {
if(this.isSortable && this.updateable) {
UIkit.sortable(this.$el.querySelector('.unite-div-table-tbody'), {
handle: '.uk-sortable-handle',
nestable: true
});
UIkit.util.on(this.$el, 'moved', this.moved);
}
},
updated() {
mounted: function(){
let findModal = (element) => {
if(element.hasAttribute('uk-modal')) {
return element;
}
if(!element.parentElement) {
return null;
}
return findModal(element.parentElement);
};
let modal = findModal(this.$el);
if(modal) {
UIkit.util.on(modal, 'beforeshow', () => {
this.selected = [];
});
}
},
setTimeout(() => {
UIkit.sortable(this.$el, {
handle: '.uk-sortable-handle',
nestableContainerClass: 'unite-div-table-tbody',
nestable: true
});
UIkit.util.on(this.$el, 'moved', this.moved);
UIkit.util.on(this.$el, 'added', this.nest);
}, 100);
});
['loadStart', 'load', 'loadEnd', 'abort'].forEach(type =>
UIkit.util.on(xhr, type.toLowerCase(), uiKitUpload[type])
);
mounted: function(){
let findModal = (element) => {
if(element.hasAttribute('uk-modal')) {
return element;
}
if(!element.parentElement) {
return null;
}
return findModal(element.parentElement);
};
let modal = findModal(this.$el);
if(modal) {
UIkit.util.on(modal, 'beforeshow', () => {
this.checked = false;
});
}
},
methods: {