Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refactoring links, popups, etc [WTEL-4531, WTEL-4528] #676

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,278 changes: 1,212 additions & 66 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@vuelidate/validators": "^2.0.0",
"@vueuse/core": "^10.3.0",
"@webitel/flow-ui-sdk": "^0.1.14",
"@webitel/ui-sdk": "^24.4.28",
"@webitel/ui-sdk": "^24.6.0",
"axios": "^1.6.8",
"clipboard-copy": "^4.0.1",
"cron-validator": "^1.3.1",
Expand Down
38 changes: 38 additions & 0 deletions src/app/components/utils/adm-item-link.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<template>
<wt-item-link
:link="link"
v-bind="attrs"
>
<slot />
</wt-item-link>
</template>

<script setup>
import { computed, useAttrs } from 'vue';
import RouteNames from '../../router/_internals/RouteNames.enum.js';

const props = defineProps({
routeName: {
type: String,
required: true,
validator: (v) => Object.values(RouteNames).includes(v),
},
id: {
type: [String, Number],
required: true,
},
});

const attrs = useAttrs();

const link = computed(() => {
return {
name: `${props.routeName}-card`,
params: { id: props.id },
};
});
</script>

<style lang="scss" scoped>

</style>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<wt-popup
min-width="480"
size="sm"
v-bind="$attrs"
@close="close"
>
<template #title>
Expand Down
8 changes: 2 additions & 6 deletions src/app/components/utils/selection-popup/selection-popup.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<wt-popup
:min-width="minWidth"
class="selection-popup"
overflow
v-bind="$attrs"
@close="close"
>
<template #title>
Expand All @@ -18,8 +18,8 @@
@click="selectOption(option)"
>
<slot
name="option"
:option="option"
name="option"
>
<wt-icon
v-if="option.icon"
Expand Down Expand Up @@ -84,10 +84,6 @@ export default {
type: Array,
default: () => [],
},
minWidth: {
type: [String, Number],
default: 480,
},
},
methods: {
add() {
Expand Down
20 changes: 12 additions & 8 deletions src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ export default {
mixins: [resetOnDestroyMixin, openedObjectValidationMixin],

computed: {
id() {
throw new Error('Override id param for a component');
},
new() {
return this.$route.params.new;
Copy link
Contributor

@RomanZaritskyi RomanZaritskyi Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ось тут я шось не поняв, вроді в роуті нема параметра new.
Чи я щось пропускаю?

Малось на увазі return this.$route.params.id = 'new'; ?

},
saveText() {
// if it's a new item
// OR any fields have changed
return !this.id || this.itemInstance._dirty
return this.new || this.itemInstance._dirty
? this.$t('objects.save') : this.$t('objects.saved');
},

disabledSave() {
// if there's a validation problem
// OR it's edit and any fields haven't changed
return this.checkValidations() ||
(!this.itemInstance._dirty && !!this.id);
(!this.itemInstance._dirty && !this.new);
},
},

Expand All @@ -45,7 +51,7 @@ export default {

async save() {
if (!this.disabledSave) {
if (this.id) {
if (!this.new) {
await this.updateItem();
} else {
try {
Expand All @@ -60,12 +66,10 @@ export default {
}
},

async redirectToEdit() {
const routeName = this.$route.name.replace('-new', '-edit');
async redirectToEdit(id = this.id) {
return this.$router.replace({
name: routeName,
params: { id: this.id },
hash: this.$route.hash,
...this.$route,
params: { id },
});
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ export default {
},
}),
create() {
this.$router.push({ name: `${this.routeName}-new` });
this.$router.push({
params: {
id: 'new',
},
});
},
edit(item) {
this.$router.push(this.editLink(item));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
mixins: [accessControlMixin],
computed: {
hasSaveActionAccess() {
if (this.$route.name.includes('-edit')) return this.hasEditAccess;
if (this.$route.params.id === 'new') return this.hasEditAccess;
return this.hasCreateAccess;
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default {
}),

async loadPageData() {
if (this.new) return;
await this.setId(this.$route.params.id);
return this.loadItem();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
mixins: [accessControlMixin],
computed: {
disableUserInput() {
if (this.$route.name.includes('-edit')) return !this.hasEditAccess;
if (this.$route.params.id === 'new') return !this.hasEditAccess;
return !this.hasCreateAccess;
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ export default {
try {
if (!this.parentId) {
await this.addParentItem();
const routeName = this.$route.name.replace('-new', '-edit');
await this.$router.replace({
name: routeName,
...this.$route,
params: { id: this.parentId },
});
}
Expand Down
Loading