parent
54663e7ddb
commit
e3f864bd71
@ -1,43 +1,42 @@ |
||||
import { useQuasar } from 'quasar'; |
||||
import { useQuasar } from "quasar" |
||||
|
||||
/** |
||||
* Use this when using Vue 3 composition api (setup) |
||||
*/ |
||||
export default function () { |
||||
const $q = useQuasar(); |
||||
const $q = useQuasar() |
||||
|
||||
function showNotification (message, type = 'success') { |
||||
let color = 'primary'; |
||||
let icon = 'info'; |
||||
function showNotification(message, type = "success") { |
||||
let color = "primary" |
||||
let icon = "info" |
||||
|
||||
switch (type) { |
||||
case 'info': |
||||
break; |
||||
case 'success': |
||||
color = 'green'; |
||||
break; |
||||
case 'error': |
||||
case 'danger': |
||||
color = 'red'; |
||||
break; |
||||
case 'warning': |
||||
color = 'yellow'; |
||||
break; |
||||
|
||||
} |
||||
if ('danger' === type) { |
||||
type = 'error'; |
||||
} |
||||
|
||||
$q.notify({ |
||||
position: 'top', |
||||
timeout: 10000, |
||||
message: message, |
||||
color: color, |
||||
html: true, |
||||
multiLine: true, |
||||
}); |
||||
switch (type) { |
||||
case "info": |
||||
break |
||||
case "success": |
||||
color = "green" |
||||
break |
||||
case "error": |
||||
case "danger": |
||||
color = "red" |
||||
break |
||||
case "warning": |
||||
color = "yellow" |
||||
break |
||||
} |
||||
if ("danger" === type) { |
||||
type = "error" |
||||
} |
||||
|
||||
$q.notify({ |
||||
position: "top", |
||||
timeout: 10000, |
||||
message: message, |
||||
color: color, |
||||
html: true, |
||||
multiLine: true, |
||||
}) |
||||
} |
||||
|
||||
return {showNotification}; |
||||
return { showNotification } |
||||
} |
||||
|
@ -1,69 +1,69 @@ |
||||
import { mapFields } from 'vuex-map-fields'; |
||||
import { useQuasar } from 'quasar'; |
||||
import { mapFields } from "vuex-map-fields" |
||||
import { useQuasar } from "quasar" |
||||
|
||||
export default { |
||||
setup() { |
||||
const quasar = useQuasar(); |
||||
const quasar = useQuasar() |
||||
|
||||
const showError = (error) => { |
||||
showMessage(error, 'danger'); |
||||
}; |
||||
showMessage(error, "danger") |
||||
} |
||||
|
||||
const showMessage = (message, type = 'success') => { |
||||
let color = 'primary'; |
||||
const showMessage = (message, type = "success") => { |
||||
let color = "primary" |
||||
|
||||
switch (type) { |
||||
case 'info': |
||||
break; |
||||
case 'success': |
||||
color = 'green'; |
||||
break; |
||||
case 'error': |
||||
case 'danger': |
||||
color = 'red'; |
||||
break; |
||||
case 'warning': |
||||
color = 'yellow'; |
||||
break; |
||||
case "info": |
||||
break |
||||
case "success": |
||||
color = "green" |
||||
break |
||||
case "error": |
||||
case "danger": |
||||
color = "red" |
||||
break |
||||
case "warning": |
||||
color = "yellow" |
||||
break |
||||
} |
||||
|
||||
quasar.notify({ |
||||
position: 'top', |
||||
position: "top", |
||||
timeout: 10000, |
||||
message: message, |
||||
color: color, |
||||
html: true, |
||||
multiLine: true, |
||||
}); |
||||
}; |
||||
}) |
||||
} |
||||
|
||||
return { |
||||
showError, |
||||
showMessage |
||||
}; |
||||
showMessage, |
||||
} |
||||
}, |
||||
methods: { |
||||
showError(error) { |
||||
this.showMessage(error, 'error'); // Use 'error' for PrimeVue
|
||||
this.showMessage(error, "error") // Use 'error' for PrimeVue
|
||||
}, |
||||
showMessage(message, type = 'success') { |
||||
showMessage(message, type = "success") { |
||||
// Convert message type to PrimeVue's severity
|
||||
let severity = type; |
||||
if (type === 'danger') { |
||||
severity = 'error'; // PrimeVue uses 'error' instead of 'danger'
|
||||
let severity = type |
||||
if (type === "danger") { |
||||
severity = "error" // PrimeVue uses 'error' instead of 'danger'
|
||||
} |
||||
|
||||
// Use PrimeVue's ToastService
|
||||
this.$toast.add({ |
||||
severity: severity, |
||||
summary: message, |
||||
detail: '', |
||||
life: 5000, // Message duration in milliseconds
|
||||
closable: true, // Whether the message can be closed manually
|
||||
}); |
||||
} |
||||
detail: "", |
||||
life: 5000, // Message duration in milliseconds
|
||||
closable: true, // Whether the message can be closed manually
|
||||
}) |
||||
}, |
||||
}, |
||||
computed: { |
||||
...mapFields('notifications', ['color', 'show', 'subText', 'text', 'timeout']) |
||||
...mapFields("notifications", ["color", "show", "subText", "text", "timeout"]), |
||||
}, |
||||
}; |
||||
} |
||||
|
@ -1,107 +1,100 @@ |
||||
import isEmpty from 'lodash/isEmpty'; |
||||
import NotificationMixin from './NotificationMixin'; |
||||
import { formatDateTime } from '../utils/dates'; |
||||
import {mapActions, mapGetters} from "vuex"; |
||||
import toInteger from "lodash/toInteger"; |
||||
import isEmpty from "lodash/isEmpty" |
||||
import NotificationMixin from "./NotificationMixin" |
||||
import { formatDateTime } from "../utils/dates" |
||||
import toInteger from "lodash/toInteger" |
||||
|
||||
export default { |
||||
mixins: [NotificationMixin], |
||||
created() { |
||||
console.log('show mixin created'); |
||||
console.log("show mixin created") |
||||
// Changed
|
||||
let id = this.$route.params.id; |
||||
let id = this.$route.params.id |
||||
if (isEmpty(id)) { |
||||
id = this.$route.query.id; |
||||
id = this.$route.query.id |
||||
} |
||||
|
||||
let cid = toInteger(this.$route.query.cid); |
||||
let sid = toInteger(this.$route.query.sid); |
||||
let gid = toInteger(this.$route.query.gid); |
||||
id = decodeURIComponent(id); |
||||
const params = {id, cid, sid, gid}; |
||||
let cid = toInteger(this.$route.query.cid) |
||||
let sid = toInteger(this.$route.query.sid) |
||||
let gid = toInteger(this.$route.query.gid) |
||||
id = decodeURIComponent(id) |
||||
const params = { id, cid, sid, gid } |
||||
|
||||
this.retrieve(params); |
||||
this.retrieve(params) |
||||
//this.retrieve(decodeURIComponent(this.$route.params.id));
|
||||
}, |
||||
computed: { |
||||
item() { |
||||
console.log('show mixin computed'); |
||||
console.log("show mixin computed") |
||||
// Changed
|
||||
let id = this.$route.params.id; |
||||
let id = this.$route.params.id |
||||
if (isEmpty(id)) { |
||||
id = this.$route.query.id; |
||||
id = this.$route.query.id |
||||
} |
||||
|
||||
let item = this.find(decodeURIComponent(id)); |
||||
let item = this.find(decodeURIComponent(id)) |
||||
|
||||
if (isEmpty(item)) { |
||||
console.log('error item is empty'); |
||||
let folderParams = this.$route.query; |
||||
delete folderParams['id']; |
||||
console.log("error item is empty") |
||||
let folderParams = this.$route.query |
||||
delete folderParams["id"] |
||||
this.$router |
||||
.push( |
||||
{ |
||||
name: `${this.$options.servicePrefix}List`, |
||||
query: folderParams |
||||
} |
||||
) |
||||
.catch(() => {}); |
||||
.push({ |
||||
name: `${this.$options.servicePrefix}List`, |
||||
query: folderParams, |
||||
}) |
||||
.catch(() => {}) |
||||
} |
||||
|
||||
return item; |
||||
return item |
||||
//return this.find(decodeURIComponent(this.$route.params.id));
|
||||
}, |
||||
}, |
||||
methods: { |
||||
goBack() { |
||||
this.$router.go(-1); |
||||
this.$router.go(-1) |
||||
}, |
||||
list() { |
||||
console.log('show mixin list'); |
||||
this.$router |
||||
.push({ name: `${this.$options.servicePrefix}List` }) |
||||
.catch(() => {}); |
||||
console.log("show mixin list") |
||||
this.$router.push({ name: `${this.$options.servicePrefix}List` }).catch(() => {}) |
||||
}, |
||||
del() { |
||||
console.log('show mixin del'); |
||||
console.log("show mixin del") |
||||
this.deleteItem(this.item).then(() => { |
||||
let folderParams = this.$route.query; |
||||
folderParams['id'] = ''; |
||||
let folderParams = this.$route.query |
||||
folderParams["id"] = "" |
||||
//this.showMessage(`${this.item['@id']} deleted.`);
|
||||
this.$router |
||||
.push( |
||||
{ |
||||
name: `${this.$options.servicePrefix}List`, |
||||
query: folderParams |
||||
} |
||||
) |
||||
.catch(() => {}); |
||||
}); |
||||
.push({ |
||||
name: `${this.$options.servicePrefix}List`, |
||||
query: folderParams, |
||||
}) |
||||
.catch(() => {}) |
||||
}) |
||||
}, |
||||
formatDateTime, |
||||
editHandler() { |
||||
console.log('show mixin editHandler'); |
||||
let folderParams = this.$route.query; |
||||
console.log("show mixin editHandler") |
||||
let folderParams = this.$route.query |
||||
if (!isEmpty(this.item)) { |
||||
folderParams['id'] = this.item['@id']; |
||||
folderParams["id"] = this.item["@id"] |
||||
} |
||||
|
||||
this.$router.push({ |
||||
name: `${this.$options.servicePrefix}Update`, |
||||
params: { id: this.item['@id'] }, |
||||
query: folderParams |
||||
}); |
||||
params: { id: this.item["@id"] }, |
||||
query: folderParams, |
||||
}) |
||||
}, |
||||
}, |
||||
watch: { |
||||
error(message) { |
||||
message && this.showError(message); |
||||
message && this.showError(message) |
||||
}, |
||||
deleteError(message) { |
||||
message && this.showError(message); |
||||
} |
||||
message && this.showError(message) |
||||
}, |
||||
}, |
||||
beforeDestroy() { |
||||
this.reset(); |
||||
} |
||||
}; |
||||
this.reset() |
||||
}, |
||||
} |
||||
|
@ -1,144 +1,144 @@ |
||||
import NotificationMixin from './NotificationMixin'; |
||||
import { formatDateTime } from '../utils/dates'; |
||||
import isEmpty from "lodash/isEmpty"; |
||||
import NotificationMixin from "./NotificationMixin" |
||||
import { formatDateTime } from "../utils/dates" |
||||
import isEmpty from "lodash/isEmpty" |
||||
|
||||
export default { |
||||
mixins: [NotificationMixin], |
||||
data() { |
||||
return { |
||||
item: {}, |
||||
}; |
||||
} |
||||
}, |
||||
created() { |
||||
// Changed
|
||||
let id = this.$route.params.id; |
||||
let id = this.$route.params.id |
||||
if (isEmpty(id)) { |
||||
id = this.$route.query.id; |
||||
id = this.$route.query.id |
||||
} |
||||
if (!isEmpty(id)) { |
||||
// Ajax call
|
||||
this.retrieve(decodeURIComponent(id)); |
||||
console.log(this.item); |
||||
this.retrieve(decodeURIComponent(id)) |
||||
console.log(this.item) |
||||
} |
||||
}, |
||||
beforeDestroy() { |
||||
this.reset(); |
||||
this.reset() |
||||
}, |
||||
computed: { |
||||
retrieved() { |
||||
// call from list
|
||||
console.log('update mixin retrieved'); |
||||
console.log("update mixin retrieved") |
||||
|
||||
let id = this.$route.params.id; |
||||
console.log('first'); |
||||
console.log(id); |
||||
let id = this.$route.params.id |
||||
console.log("first") |
||||
console.log(id) |
||||
if (isEmpty(id)) { |
||||
console.log('second'); |
||||
id = this.$route.query.id; |
||||
console.log(id); |
||||
console.log("second") |
||||
id = this.$route.query.id |
||||
console.log(id) |
||||
} |
||||
|
||||
if (!isEmpty(id)) { |
||||
let item = this.find(decodeURIComponent(id)); |
||||
let item = this.find(decodeURIComponent(id)) |
||||
|
||||
if (isEmpty(item)) { |
||||
//this.retrieve(decodeURIComponent(id));
|
||||
} |
||||
|
||||
return item; |
||||
return item |
||||
} |
||||
} |
||||
}, |
||||
}, |
||||
methods: { |
||||
del() { |
||||
console.log('mixin del'); |
||||
console.log(this.item); |
||||
console.log("mixin del") |
||||
console.log(this.item) |
||||
|
||||
this.deleteItem(this.item).then(() => { |
||||
console.log('deleteItem resykt'); |
||||
let folderParams = this.$route.query; |
||||
console.log("deleteItem resykt") |
||||
let folderParams = this.$route.query |
||||
|
||||
delete folderParams['id']; |
||||
delete folderParams['getFile']; |
||||
delete folderParams["id"] |
||||
delete folderParams["getFile"] |
||||
|
||||
//this.showMessage(`${this.item['@id']} deleted.`);
|
||||
this.$router |
||||
.push({ |
||||
name: `${this.$options.servicePrefix}List`, |
||||
query: folderParams |
||||
query: folderParams, |
||||
}) |
||||
.catch(() => {}); |
||||
}); |
||||
console.log('end mixin del()'); |
||||
.catch(() => {}) |
||||
}) |
||||
console.log("end mixin del()") |
||||
}, |
||||
formatDateTime, |
||||
reset() { |
||||
this.$refs.updateForm.v$.$reset(); |
||||
this.updateReset(); |
||||
this.delReset(); |
||||
this.createReset(); |
||||
this.$refs.updateForm.v$.$reset() |
||||
this.updateReset() |
||||
this.delReset() |
||||
this.createReset() |
||||
}, |
||||
onSendForm() { |
||||
console.log('onSendForm'); |
||||
const updateForm = this.$refs.updateForm; |
||||
updateForm.v$.$touch(); |
||||
console.log("onSendForm") |
||||
const updateForm = this.$refs.updateForm |
||||
updateForm.v$.$touch() |
||||
if (!updateForm.v$.$invalid) { |
||||
this.update(updateForm.v$.item.$model); |
||||
this.item = { ...this.retrieved }; |
||||
this.update(updateForm.v$.item.$model) |
||||
this.item = { ...this.retrieved } |
||||
} |
||||
}, |
||||
onSendFormData() { |
||||
console.log('onSendForm'); |
||||
const updateForm = this.$refs.updateForm; |
||||
updateForm.v$.$touch(); |
||||
console.log("onSendForm") |
||||
const updateForm = this.$refs.updateForm |
||||
updateForm.v$.$touch() |
||||
if (!updateForm.v$.$invalid) { |
||||
this.updateWithFormData(updateForm.v$.item.$model); |
||||
this.item = { ...this.retrieved }; |
||||
this.updateWithFormData(updateForm.v$.item.$model) |
||||
this.item = { ...this.retrieved } |
||||
} |
||||
}, |
||||
resetForm() { |
||||
console.log('resetForm'); |
||||
this.$refs.updateForm.v$.$reset(); |
||||
this.item = { ...this.retrieved }; |
||||
} |
||||
console.log("resetForm") |
||||
this.$refs.updateForm.v$.$reset() |
||||
this.item = { ...this.retrieved } |
||||
}, |
||||
}, |
||||
watch: { |
||||
deleted(deleted) { |
||||
console.log('deleted'); |
||||
console.log("deleted") |
||||
if (!deleted) { |
||||
return; |
||||
return |
||||
} |
||||
|
||||
let folderParams = this.$route.query; |
||||
let folderParams = this.$route.query |
||||
this.$router |
||||
.push({ |
||||
name: `${this.$options.servicePrefix}List`, |
||||
query: folderParams |
||||
query: folderParams, |
||||
}) |
||||
.catch(() => {}); |
||||
.catch(() => {}) |
||||
}, |
||||
|
||||
error(message) { |
||||
console.log('error'); |
||||
message && this.showError(message); |
||||
console.log("error") |
||||
message && this.showError(message) |
||||
}, |
||||
|
||||
deleteError(message) { |
||||
console.log('deleteError'); |
||||
message && this.showError(message); |
||||
console.log("deleteError") |
||||
message && this.showError(message) |
||||
}, |
||||
|
||||
updated(val) { |
||||
console.log('updated'); |
||||
console.log("updated") |
||||
//this.showMessage(`${val['@id']} updated.`);
|
||||
this.$router.go(-1); |
||||
this.$router.go(-1) |
||||
}, |
||||
|
||||
retrieved(val) { |
||||
console.log('retrieved(val)'); |
||||
console.log("retrieved(val)") |
||||
if (!isEmpty(val)) { |
||||
this.item = {...val}; |
||||
this.item = { ...val } |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
}, |
||||
}, |
||||
} |
||||
|
@ -1,33 +1,33 @@ |
||||
import NotificationMixin from './NotificationMixin'; |
||||
import { formatDateTime } from '../utils/dates'; |
||||
import NotificationMixin from "./NotificationMixin" |
||||
import { formatDateTime } from "../utils/dates" |
||||
|
||||
export default { |
||||
mixins: [NotificationMixin], |
||||
methods: { |
||||
formatDateTime, |
||||
onCreated(item) { |
||||
this.showMessage(this.$i18n.t('{resource} created', {'resource': item['resourceNode'].title})); |
||||
this.showMessage(this.$i18n.t("{resource} created", { resource: item["resourceNode"].title })) |
||||
}, |
||||
onUploadForm() { |
||||
console.log('onUploadForm'); |
||||
const createForm = this.$refs.createForm; |
||||
console.log("onUploadForm") |
||||
const createForm = this.$refs.createForm |
||||
for (let i = 0; i < createForm.files.length; i++) { |
||||
let file = createForm.files[i]; |
||||
this.create(file); |
||||
let file = createForm.files[i] |
||||
this.create(file) |
||||
} |
||||
}, |
||||
}, |
||||
watch: { |
||||
created(created) { |
||||
if (!created) { |
||||
return; |
||||
return |
||||
} |
||||
|
||||
this.onCreated(created); |
||||
this.onCreated(created) |
||||
}, |
||||
|
||||
error(message) { |
||||
message && this.showError(message); |
||||
} |
||||
} |
||||
}; |
||||
message && this.showError(message) |
||||
}, |
||||
}, |
||||
} |
||||
|
@ -1,18 +1,11 @@ |
||||
//import './styles/quasar.sass'
|
||||
import '@quasar/extras/material-icons/material-icons.css' |
||||
import "@quasar/extras/material-icons/material-icons.css" |
||||
|
||||
import {Dialog, Notify} from 'quasar' |
||||
import { Dialog, Notify } from "quasar" |
||||
|
||||
export default { |
||||
config: { |
||||
notify: { |
||||
} |
||||
notify: {}, |
||||
}, |
||||
plugins: [ |
||||
Notify, |
||||
Dialog, |
||||
], |
||||
extras: [ |
||||
'material-icons', |
||||
] |
||||
} |
||||
plugins: [Notify, Dialog], |
||||
extras: ["material-icons"], |
||||
} |
||||
|
Loading…
Reference in new issue