Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chamilo-lms/assets/vue/mixins/CreateMixin.js

47 lines
1.0 KiB

import NotificationMixin from './NotificationMixin';
import { formatDateTime } from '../utils/dates';
export default {
mixins: [NotificationMixin],
methods: {
formatDateTime,
onCreated(item) {
this.showMessage(`${item['@id']} created`);
this.$router.push({
name: `${this.$options.servicePrefix}Update`,
params: { id: item['@id'] }
});
},
onSendForm() {
const createForm = this.$refs.createForm;
createForm.$v.$touch();
5 years ago
if (createForm.$v.item.parentResourceNode) {
let nodeId = this.$route.params.node;
createForm.$v.item.$model.parentResourceNode = '/api/resource_nodes/' + nodeId;
}
if (!createForm.$v.$invalid) {
this.create(createForm.$v.item.$model);
}
},
resetForm() {
this.$refs.createForm.$v.$reset();
this.item = {};
}
},
watch: {
created(created) {
if (!created) {
return;
}
this.onCreated(created);
},
error(message) {
message && this.showError(message);
}
}
};