Minor: Format code

pull/5889/head
Angel Fernando Quiroz Campos 11 months ago
parent 54663e7ddb
commit e3f864bd71
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 65
      assets/vue/components/Notification.js
  2. 24
      assets/vue/composables/notification.js
  3. 72
      assets/vue/mixins/NotificationMixin.js
  4. 107
      assets/vue/mixins/ShowMixin.js
  5. 126
      assets/vue/mixins/UpdateMixin.js
  6. 26
      assets/vue/mixins/UploadMixin.js
  7. 19
      assets/vue/quasar-user-options.js
  8. 28
      assets/vue/views/ccalendarevent/CCalendarEventCreate.vue

@ -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,37 +1,37 @@
import {useToast} from "primevue/usetoast";
import { useToast } from "primevue/usetoast"
// This is the migration from assets/vue/mixins/NotificationMixin.js to composables
// some components still use UploadMixin with options API, this should be use
// when migrating from options API to composition API
export function useNotification() {
const toast = useToast();
const toast = useToast()
const showSuccessNotification = (message) => {
showMessage(message, 'success')
showMessage(message, "success")
}
const showInfoNotification = (error) => {
showMessage(error, 'info');
showMessage(error, "info")
}
const showWarningNotification = (message) => {
showMessage(message, 'warn')
showMessage(message, "warn")
}
const showErrorNotification = (error) => {
let message = error;
let message = error
if (error.response) {
if (error.response.data) {
message = error.response.data['hydra:description'];
message = error.response.data["hydra:description"]
}
} else if (error.message) {
message = error.message;
} else if (typeof(error) === 'string') {
message = error;
message = error.message
} else if (typeof error === "string") {
message = error
}
showMessage(message, 'error');
showMessage(message, "error")
}
const showMessage = (message, severity) => {
@ -39,7 +39,7 @@ export function useNotification() {
severity: severity,
detail: message,
life: 3500,
});
})
}
return {

@ -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"],
}

@ -31,7 +31,7 @@ import { useNotification } from "../../composables/notification"
const item = ref({})
const store = useStore()
const securityStore = useSecurityStore();
const securityStore = useSecurityStore()
const route = useRoute()
const router = useRouter()
const { t } = useI18n()
@ -43,16 +43,16 @@ if (isEmpty(id)) {
id = route.query.id
}
const isLoading = ref(true);
const isLoading = ref(true)
onMounted(async () => {
isLoading.value = true
const response = await store.dispatch("message/load", id)
const currentUser = securityStore.user;
const currentUser = securityStore.user
item.value = await response
isLoading.value = false;
isLoading.value = false
// Remove unused properties:
delete item.value["status"]
@ -74,7 +74,7 @@ onMounted(async () => {
// Set new receivers, will be loaded by onSendMessageForm()
item.value.resourceLinkListFromEntity = []
const receivers = [...item.value.receiversTo, ...item.value.receiversCc];
const receivers = [...item.value.receiversTo, ...item.value.receiversCc]
let itemsAdded = []
receivers.forEach((receiver) => {
// Skip current user.
@ -104,34 +104,32 @@ onMounted(async () => {
const onClickCreateEvent = async () => {
if (createForm.value.v$.$invalid) {
return;
return
}
isLoading.value = true;
isLoading.value = true
const itemModel = createForm.value.v$.item.$model
try {
await store.dispatch("ccalendarevent/create", itemModel)
} catch (e) {
isLoading.value = false;
isLoading.value = false
notification.showErrorNotification(e)
return;
return
}
await router.push({ name: 'CCalendarEventList' })
await router.push({ name: "CCalendarEventList" })
}
const notification = useNotification();
const notification = useNotification()
watch(
() => store.state.ccalendarevent.created,
(created) => {
notification.showSuccessNotification(
t("{resource} created", { resource: created.resourceNode.title })
)
notification.showSuccessNotification(t("{resource} created", { resource: created.resourceNode.title }))
},
)
</script>
</script>

Loading…
Cancel
Save