Adds routeLeave check on ItemEditionPage to warn leaving when is 'auto-draft'. Removes console.log on tainacan-form-item.

This commit is contained in:
mateuswetah 2018-05-06 17:45:48 -03:00
parent 3c805a5494
commit 3c27e36d9d
3 changed files with 19 additions and 4 deletions

View File

@ -603,10 +603,22 @@ export default {
// Fetch current existing attachments
this.fetchAttachments(this.itemId);
}
},
beforeRouteLeave ( to, from, next ) {
if (this.item.status == 'auto-draft') {
this.$dialog.confirm({
message: this.$i18n.get('info_warning_item_not_saved'),
onConfirm: () => {
next();
},
cancelText: this.$i18n.get('cancel'),
confirmText: this.$i18n.get('continue'),
type: 'is-secondary'
});
} else {
next()
}
}
}
</script>

View File

@ -223,6 +223,7 @@ return [
'info_by' => __( 'By: ', 'tainacan' ),
'info_date' => __( 'Date: ', 'tainacan' ),
'info_not_saved' => __( 'Not saved ', 'tainacan' ),
'info_warning_item_not_saved' => __( 'Are you sure? The item is not saved, changes will be lost.', 'tainacan' ),
'info_warning_fields_not_saved' => __( 'Are you sure? There are fields not saved, changes will be lost.', 'tainacan' ),
'info_warning_filters_not_saved' => __( 'Are you sure? There are filters not saved, changes will be lost.', 'tainacan' ),
'info_no_description_provided' => __( 'No description provided.', 'tainacan' ),

View File

@ -92,7 +92,7 @@
this.setFieldTypeMessage('is-danger');
for (let error of errors) {
for (let index of Object.keys(error)) {
this.$console.log(index);
//this.$console.log(index);
msg += error[index] + '\n';
}
}
@ -133,6 +133,8 @@
},
setFieldTypeMessage( message ){
this.fieldTypeMessage = message;
//if (message != '')
//this.isCollapsed = false;
}
}
}