Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
micnori committed Nov 18, 2024
2 parents a9abe68 + 32251c9 commit 60b3cc3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
</v-col>
<v-col cols="3">
<v-select

label="Territorio"
name="territoryId"
id="territoryId"
Expand Down Expand Up @@ -229,18 +228,18 @@
</v-row>
<v-row>
<v-col cols="6">
<img v-if="imgUrl"
<img
v-if="imgUrl"
:width="300"
aspect-ratio="16/9"
cover
:src="imgUrl"
alt="Immagine non disponibile"
@error="errorUrl"
>
/>
<div v-else>
<p class="text-h5 text-center"> Immagine non disponibile</p>
<p class="text-h5 text-center">Immagine non disponibile</p>
</div>

</v-col>
<v-col cols="6">
<v-text-field
Expand All @@ -250,7 +249,7 @@
name="companyLogo"
id="companyLogo"
v-model.trim="$v.logo.$model"
@input="event => onChangeUrl($v.logo.$model)"
@input="(event) => onChangeUrl($v.logo.$model)"
outlined
>
<template v-slot:append>
Expand Down Expand Up @@ -295,6 +294,14 @@ export default {
},
code: {
required,
unique() {
return (
(this.actualCompany &&
this.actualCompany.item &&
this.code === this.actualCompany.item.code) ||
!this.allCompanies.items.find((l) => l.code === this.code)
);
},
},
territoryId: {
required,
Expand Down Expand Up @@ -343,6 +350,14 @@ export default {
},
code: {
required,
unique() {
return (
(this.actualCompany &&
this.actualCompany.item &&
this.code === this.actualCompany.item.code) ||
!this.allCompanies.items.find((l) => l.code === this.code)
);
},
},
territoryId: {
required,
Expand Down Expand Up @@ -757,7 +772,7 @@ export default {
contactPhone: "",
web: "",
logo: "",
imgUrl:"",
imgUrl: "",
popup: {
title: "",
},
Expand All @@ -769,9 +784,9 @@ export default {
...mapActions("company", {
addCompany: "addCompany",
updateCompany: "updateCompany",
getAllCompanies: "getAllCompanies",
}),
...mapActions("campaign", { getTerritories: "getTerritories" }),
copyFormValues(company) {
if (!company) return;
for (const [key] of Object.entries(company)) {
Expand All @@ -782,18 +797,18 @@ export default {
this.imgUrl = url;
},
errorUrl() {
this.imgUrl=null;
this.imgUrl = null;
},
isURL(str) {
let url;
if (str) {
try {
url = new URL(str);
} catch (_) {
return false;
}
return url.protocol === "http:" || url.protocol === "https:";
} else return true;
try {
url = new URL(str);
} catch (_) {
return false;
}
return url.protocol === "http:" || url.protocol === "https:";
} else return true;
},
validateEmail(email) {
var re = /\S+@\S+\.\S+/;
Expand Down Expand Up @@ -879,7 +894,7 @@ export default {
if (this.typeCall == "add") {
this.addCompany(this.company);
this.$v.$reset();
this.closeModal();
this.closeModal();
} else if (this.typeCall == "edit") {
console.log(this.company);
this.updateCompany(this.company);
Expand Down Expand Up @@ -908,7 +923,7 @@ export default {
},
computed: {
...mapState("company", ["actualCompany"]),
...mapState("company", ["actualCompany", "allCompanies"]),
...mapState("campaign", ["territories"]),
...mapState("modal", ["type"]),
...mapState("account", ["user"]),
Expand All @@ -924,6 +939,7 @@ export default {
const errors = [];
if (!this.$v.code.$dirty) return errors;
!this.$v.code.required && errors.push("Campo richiesto.");
!this.$v.code.unique && errors.push("Valore gia' in uso.");
return errors;
},
addressErrors() {
Expand Down Expand Up @@ -1005,12 +1021,12 @@ export default {
!this.user.permissions.admin &&
!this.$v.web.required &&
errors.push("Campo richiesto.");
!this.isURL(this.web) &&
!this.isURL(this.web) &&
errors.push('Inserisci un url con "http://" o "https://".');
return errors;
},
territoryErrors() {
console.log('error territory')
console.log("error territory");
const errors = [];
if (!this.$v.territoryId.$dirty) return errors;
!this.$v.territoryId.required && errors.push("Campo richiesto.");
Expand All @@ -1035,7 +1051,7 @@ export default {
mounted() {
this.setModalData();
this.getTerritories();
this.imgUrl=this.$v.logo.$model;
this.imgUrl = this.$v.logo.$model;
},
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@
id="companyLocation"
v-model.trim="$v.location.$model"
:items="listaSedi"
:error-messages="locationErrors"
:error-messages="locationErrors"
:item-text="item=>`${item.id}${item.name?(' - '+item.name):''}`"
item-value="id"
required
@input="$v.location.$touch()"
@blur="$v.location.$touch()"
Expand Down Expand Up @@ -258,7 +260,7 @@ export default {
{
for (let i=0;i<locations.items.length; i++)
{
this.listaSedi.push(locations.items[i].id);}
this.listaSedi.push(locations.items[i]);}
console.log(this.listaSedi);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
v-on:returnGeosearch="geoSearchResult"
/>
</div>
<v-row v-if="latitude && longitude">
<v-row v-if="tmpLocationSelected">
<v-col cols="12">
<p class="text-subtitle-1 mt-5 bg-warning p-2 position-warning">
<b>ATTENZIONE!</b> La posizione sarà utilizzata per la validazione dei
Expand Down

0 comments on commit 60b3cc3

Please sign in to comment.