WIP: #7701: Make FormModel use url #1653
|
@ -0,0 +1,4 @@
|
|||
import setDefault from './setDefault';
|
||||
import { QDialog } from 'quasar';
|
||||
|
||||
setDefault(QDialog, 'noRouteDismiss', true);
|
|
@ -2,3 +2,4 @@
|
|||
export * from './defaults/qTable';
|
||||
export * from './defaults/qInput';
|
||||
export * from './defaults/qSelect';
|
||||
export * from './defaults/qDialog';
|
||||
|
|
|
@ -21,6 +21,7 @@ const { t } = useI18n();
|
|||
const { validate, validations } = useValidator();
|
||||
const { notify } = useNotify();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const myForm = ref(null);
|
||||
const attrs = useAttrs();
|
||||
const $props = defineProps({
|
||||
|
@ -99,6 +100,10 @@ const $props = defineProps({
|
|||
type: Function,
|
||||
default: () => {},
|
||||
},
|
||||
searchUrl: {
|
||||
type: [String, Boolean],
|
||||
default: 'form',
|
||||
},
|
||||
});
|
||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||
const modelValue = computed(
|
||||
|
@ -139,6 +144,11 @@ const submitForm = async (evt) => {
|
|||
};
|
||||
|
||||
onMounted(async () => {
|
||||
const urlInitalData =
|
||||
$props.searchUrl && JSON.parse(route?.query[$props.searchUrl] ?? '{}');
|
||||
originalData.value = JSON.parse(
|
||||
JSON.stringify(urlInitalData ?? $props.formInitialData ?? {}),
|
||||
);
|
||||
nextTick(() => (componentIsRendered.value = true));
|
||||
|
||||
// Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla
|
||||
|
@ -187,6 +197,24 @@ watch(
|
|||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => formData.value,
|
||||
async (newData, oldData) => {
|
||||
if (JSON.stringify(newData) === JSON.stringify(oldData)) return;
|
||||
if (!$props.searchUrl) return;
|
||||
if (!newData) return;
|
||||
const urlParams = JSON.stringify(newData);
|
||||
await nextTick();
|
||||
router.replace({
|
||||
query: {
|
||||
...route.query,
|
||||
createForm: urlParams,
|
||||
},
|
||||
});
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
onBeforeRouteLeave((to, from, next) => {
|
||||
if (hasChanges.value && $props.observeFormChanges)
|
||||
quasar.dialog({
|
||||
|
|
|
@ -208,13 +208,6 @@ onMounted(async () => {
|
|||
...['tableActions'],
|
||||
];
|
||||
createForm.value = $props.create;
|
||||
if ($props.create && route?.query?.createForm) {
|
||||
showForm.value = true;
|
||||
createForm.value = {
|
||||
...createForm.value,
|
||||
...{ formInitialData: JSON.parse(route?.query?.createForm) },
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(async () => {
|
||||
|
|
|
@ -4,6 +4,8 @@ describe('Client web-access', () => {
|
|||
cy.viewport(1280, 720);
|
||||
cy.login('developer');
|
||||
});
|
||||
|
||||
//falla
|
||||
it('Should test buttons ', () => {
|
||||
cy.visit('#/customer/1101/web-access');
|
||||
cy.get('.q-page').should('be.visible');
|
||||
|
|
|
@ -12,6 +12,7 @@ describe('Item botanical', () => {
|
|||
cy.checkNotification('Data saved');
|
||||
});
|
||||
|
||||
//falla
|
||||
it('should create a new Genus', () => {
|
||||
cy.dataCy('Genus_icon').click();
|
||||
cy.dataCy('Latin genus name_input').type('Test');
|
||||
|
@ -19,6 +20,7 @@ describe('Item botanical', () => {
|
|||
cy.checkNotification('Data created');
|
||||
});
|
||||
|
||||
//falla
|
||||
it('should create a new specie', () => {
|
||||
cy.dataCy('Species_icon').click();
|
||||
cy.dataCy('Latin species name_input').type('Test specie');
|
||||
|
|
|
@ -13,6 +13,7 @@ describe('Item summary', () => {
|
|||
cy.dataCy('itemTags').should('be.visible');
|
||||
});
|
||||
|
||||
//falla
|
||||
it('should regularize stock', () => {
|
||||
cy.dataCy('descriptor-more-opts').click();
|
||||
cy.get('.q-menu > .q-list > :nth-child(1) > .q-item__section').click();
|
||||
|
|
Loading…
Reference in New Issue