diff --git a/src/pages/Worker/WorkerCreate.vue b/src/pages/Worker/WorkerCreate.vue
index 9efdde879..3ded85584 100644
--- a/src/pages/Worker/WorkerCreate.vue
+++ b/src/pages/Worker/WorkerCreate.vue
@@ -9,7 +9,8 @@ import VnInputDate from 'components/common/VnInputDate.vue';
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
import VnSelectCreate from 'src/components/common/VnSelectCreate.vue';
import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
-import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
+import CustomerCreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
+import VnLocation from 'src/components/common/VnLocation.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
@@ -21,14 +22,6 @@ const workerConfigFilter = {
field: ['payMethodFk'],
};
-const provincesFilter = {
- fields: ['id', 'name', 'countryFk'],
-};
-
-const townsFilter = {
- fields: ['id', 'name', 'provinceFk'],
-};
-
const newWorkerForm = ref({
companyFk: null,
payMethodFk: null,
@@ -49,10 +42,6 @@ const newWorkerForm = ref({
bankEntityFk: null,
});
-const postcodeFetchDataRef = ref(null);
-const townsFetchDataRef = ref(null);
-const provincesOptions = ref([]);
-const townsOptions = ref([]);
const companiesOptions = ref([]);
const workersOptions = ref([]);
const payMethodsOptions = ref([]);
@@ -67,13 +56,14 @@ const onBankEntityCreated = (data) => {
bankEntitiesOptions.value.push(data);
};
-const onPostcodeCreated = async ({ code, provinceFk, townFk }, formData) => {
- await postcodeFetchDataRef.value.fetch();
- await townsFetchDataRef.value.fetch();
- formData.postcode = code;
- formData.provinceFk = provinceFk;
- formData.city = townsOptions.value.find((town) => town.id === townFk).name;
-};
+
+function handleLocation(data, location ) {
+ const { town, postcode: code, provinceFk, countryFk } = location ?? {}
+ data.postcode = code;
+ data.city = town;
+ data.provinceFk = provinceFk;
+ data.countryFk = countryFk;
+}
onMounted(async () => {
const userInfo = await useUserConfig().fetch();
@@ -88,25 +78,7 @@ onMounted(async () => {
:filter="workerConfigFilter"
auto-load
/>
-
(postcodesOptions = data)"
- auto-load
- />
- (provincesOptions = data)"
- :filter="provincesFilter"
- auto-load
- />
- (townsOptions = data)"
- :filter="townsFilter"
- auto-load
- />
+
(companiesOptions = data)"
@@ -184,77 +156,19 @@ onMounted(async () => {
-
-
-
-
-
-
-
- {{ scope.opt.code }}
- {{ scope.opt.code }} -
- {{ scope.opt.town.name }} ({{
- scope.opt.town.province.name
- }},
- {{
- scope.opt.town.province.country.country
- }})
-
-
-
-
-
-
-
+ v-model="data.location"
+ @update:model-value="
+ (location) => handleLocation(data, location)
+ "
+ >
+
-
-
-
-
-
- {{ scope.opt.name }}
- {{ scope.opt.name }},
- {{ scope.opt.province.name }} ({{
- scope.opt.province.country.country
- }})
-
-
-
-
-
{
+ beforeEach(() => {
+ cy.viewport(1280, 720);
+ cy.login('developer');
+ cy.visit('/#/worker/create');
+ cy.waitForElement('.q-card');
+ });
+
+ it('Show all options', function() {
+ cy.get(inputLocation).click();
+ cy.get(locationOptions).should('have.length',5);
+ });
+
+ it('input filter location as "al"', function() {
+ cy.get(inputLocation).click();
+ cy.get(inputLocation).clear();
+ cy.get(inputLocation).type('al');
+ cy.get(locationOptions).should('have.length',3);
+ });
+ it('input filter location as "ecuador"', function() {
+ cy.get(inputLocation).click();
+ cy.get(inputLocation).clear();
+ cy.get(inputLocation).type('ecuador');
+ cy.get(locationOptions).should('have.length',1);
+ cy.get(`${locationOptions}:nth-child(1)`).click();
+ cy.get(':nth-child(3) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control > :nth-child(2) > .q-icon').click();
+
+ });
+})