Verified Commit 34311272 authored by Florian Azizian's avatar Florian Azizian

Merge branch 'develop' of labs.maarch.org:maarch/MaarchCourrier into develop

parents d7a90aa9 2ab76cdd
...@@ -132,4 +132,26 @@ ...@@ -132,4 +132,26 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
}
.actionValuesCustom {
display: flex;
}
.alert-message-info {
margin-top: 30px;
max-width: 100%;
}
.addCustomFieldTypeContainer {
justify-content: center;
display: flex;
align-items: center;
width:60px;
}
.customFieldsTypesItem {
display:flex;
padding-top: 10px;
padding-bottom: 10px;
} }
\ No newline at end of file
...@@ -27,7 +27,6 @@ export class CustomFieldsAdministrationComponent implements OnInit { ...@@ -27,7 +27,6 @@ export class CustomFieldsAdministrationComponent implements OnInit {
lang: any = LANG; lang: any = LANG;
loading: boolean = false; loading: boolean = false;
creationMode: any = false;
customFieldsTypes: any[] = [ customFieldsTypes: any[] = [
{ {
...@@ -51,17 +50,13 @@ export class CustomFieldsAdministrationComponent implements OnInit { ...@@ -51,17 +50,13 @@ export class CustomFieldsAdministrationComponent implements OnInit {
type: 'checkbox' type: 'checkbox'
} }
] ]
customFields: any[] = [ customFields: any[] = [];
{ customFieldsClone: any[] = [];
id: 4,
label: 'Nouveau champ', incrementCreation: number = 1;
type: 'select',
values: [], sampleIncrement: number[] = [1,2,3,4];
default_value: ''
}
];
customFieldClone: any;
dialogRef: MatDialogRef<any>; dialogRef: MatDialogRef<any>;
...@@ -85,18 +80,18 @@ export class CustomFieldsAdministrationComponent implements OnInit { ...@@ -85,18 +80,18 @@ export class CustomFieldsAdministrationComponent implements OnInit {
// TO FIX DATA BINDING SIMPLE ARRAY VALUES // TO FIX DATA BINDING SIMPLE ARRAY VALUES
map((data: any) => { map((data: any) => {
data.customFields.forEach((element: any) => { data.customFields.forEach((element: any) => {
if (element.values != null) { element.values = element.values.map((info: any) => {
element.values = element.values.map((info: any) => { return {
return { label: info
label: info }
} });
});
}
}); });
return data; return data;
}), }),
tap((data: any) => { tap((data: any) => {
this.customFields = data.customFields; this.customFields = data.customFields;
this.customFieldsClone = JSON.parse(JSON.stringify(this.customFields));
}), }),
finalize(() => this.loading = false), finalize(() => this.loading = false),
catchError((err: any) => { catchError((err: any) => {
...@@ -116,7 +111,7 @@ export class CustomFieldsAdministrationComponent implements OnInit { ...@@ -116,7 +111,7 @@ export class CustomFieldsAdministrationComponent implements OnInit {
filter((data: string) => data === 'ok'), filter((data: string) => data === 'ok'),
tap(() => { tap(() => {
newCustomField = { newCustomField = {
label: 'Nouveau champ', label: this.lang.newField + ' ' + this.incrementCreation,
type: customFieldType.type, type: customFieldType.type,
values: [], values: [],
default_value: '' default_value: ''
...@@ -127,6 +122,7 @@ export class CustomFieldsAdministrationComponent implements OnInit { ...@@ -127,6 +122,7 @@ export class CustomFieldsAdministrationComponent implements OnInit {
newCustomField.id = data.customFieldId newCustomField.id = data.customFieldId
this.customFields.push(newCustomField); this.customFields.push(newCustomField);
this.notify.success(this.lang.customFieldAdded); this.notify.success(this.lang.customFieldAdded);
this.incrementCreation++;
}), }),
catchError((err: any) => { catchError((err: any) => {
this.notify.handleErrors(err); this.notify.handleErrors(err);
...@@ -138,7 +134,7 @@ export class CustomFieldsAdministrationComponent implements OnInit { ...@@ -138,7 +134,7 @@ export class CustomFieldsAdministrationComponent implements OnInit {
addValue(indexCustom: number) { addValue(indexCustom: number) {
this.customFields[indexCustom].values.push( this.customFields[indexCustom].values.push(
{ {
label: 'Nouvelle donnée' label: this.lang.newValue
} }
); );
} }
...@@ -152,8 +148,10 @@ export class CustomFieldsAdministrationComponent implements OnInit { ...@@ -152,8 +148,10 @@ export class CustomFieldsAdministrationComponent implements OnInit {
this.dialogRef.afterClosed().pipe( this.dialogRef.afterClosed().pipe(
filter((data: string) => data === 'ok'), filter((data: string) => data === 'ok'),
exhaustMap(() => this.http.delete('../../rest/customFields/' + this.customFields[indexCustom].id)),
tap(() => { tap(() => {
this.customFields.splice(indexCustom, 1); this.customFields.splice(indexCustom, 1);
this.notify.success(this.lang.customFieldDeleted);
}), }),
catchError((err: any) => { catchError((err: any) => {
this.notify.handleErrors(err); this.notify.handleErrors(err);
...@@ -162,13 +160,12 @@ export class CustomFieldsAdministrationComponent implements OnInit { ...@@ -162,13 +160,12 @@ export class CustomFieldsAdministrationComponent implements OnInit {
).subscribe(); ).subscribe();
} }
updateCustomField(customField: any) { updateCustomField(customField: any, indexCustom: number) {
// TO FIX DATA BINDING SIMPLE ARRAY VALUES // TO FIX DATA BINDING SIMPLE ARRAY VALUES
const customFieldToUpdate = { ...customField }; const customFieldToUpdate = { ...customField };
if (customField.values != null) {
customFieldToUpdate.values = customField.values.map((data: any) => data.label) customFieldToUpdate.values = customField.values.map((data: any) => data.label)
}
const alreadyExists = this.customFields.filter(customField => customField.label == customFieldToUpdate.label ); const alreadyExists = this.customFields.filter(customField => customField.label == customFieldToUpdate.label );
if (alreadyExists.length > 1) { if (alreadyExists.length > 1) {
...@@ -178,6 +175,7 @@ export class CustomFieldsAdministrationComponent implements OnInit { ...@@ -178,6 +175,7 @@ export class CustomFieldsAdministrationComponent implements OnInit {
this.http.put('../../rest/customFields/' + customField.id, customFieldToUpdate).pipe( this.http.put('../../rest/customFields/' + customField.id, customFieldToUpdate).pipe(
tap(() => { tap(() => {
this.customFieldsClone[indexCustom] = customField;
this.notify.success(this.lang.customFieldUpdated); this.notify.success(this.lang.customFieldUpdated);
}), }),
catchError((err: any) => { catchError((err: any) => {
...@@ -191,13 +189,8 @@ export class CustomFieldsAdministrationComponent implements OnInit { ...@@ -191,13 +189,8 @@ export class CustomFieldsAdministrationComponent implements OnInit {
customField.values = this.sortPipe.transform(customField.values, 'label'); customField.values = this.sortPipe.transform(customField.values, 'label');
} }
initCustomFieldCheck(customField: any) { isModified(customField: any, indexCustomField: number) {
console.log('init'); if (JSON.stringify(customField) === JSON.stringify(this.customFieldsClone[indexCustomField])) {
this.customFieldClone = JSON.parse(JSON.stringify(customField));
}
isModified(customField: any) {
if (JSON.stringify(customField) === JSON.stringify(this.customFieldClone)) {
return true; return true;
} else { } else {
return false; return false;
......
...@@ -1081,5 +1081,21 @@ export const LANG_EN = { ...@@ -1081,5 +1081,21 @@ export const LANG_EN = {
"dateInput" : "Date input", "dateInput" : "Date input",
"radioInput" : "Radio input", "radioInput" : "Radio input",
"checkboxInput" : "Checbox input", "checkboxInput" : "Checbox input",
"customFieldAlreadyExists" : "Custom fields already exists with this name" "customFieldAlreadyExists" : "Custom fields already exists with this name",
"newField" : "New field",
"newValue" : "New value",
"customFieldAdded" : "Custom field added",
"customFieldUpdated" : "Custom field updated",
"customFieldDeleted" : "Custom field deleted",
"usableFields" : "Usable field(s)",
"noCustomFieldInfo" : "<b>No custom field</b> available, choose avaiblable custom fields types on <b>right panel</b> in order to create new custom fields.",
"defaultValue" : "Default value",
"valuesList" : "List of values",
"addValue" : "Add a value",
"orderValues" : "Order values",
"customFieldsTypesAvailable" : "Custom fields types available",
"typeValue" : "Type a value",
"chooseDate" : "Choose a date",
"selectedValue" : "Selected value",
"choice" : "Choice",
}; };
...@@ -1118,5 +1118,21 @@ export const LANG_FR = { ...@@ -1118,5 +1118,21 @@ export const LANG_FR = {
"dateInput" : "Champ date", "dateInput" : "Champ date",
"radioInput" : "Liste à choix unique", "radioInput" : "Liste à choix unique",
"checkboxInput" : "Liste à choix multiple", "checkboxInput" : "Liste à choix multiple",
"customFieldAlreadyExists" : "Un champ personnalisé existe déjà avec ce nom" "customFieldAlreadyExists" : "Un champ personnalisé existe déjà avec ce nom",
"newField" : "Nouveau champ",
"newValue" : "Nouvelle donnée",
"customFieldAdded" : "Champ personnalisé ajouté",
"customFieldUpdated" : "Champ personnalisé modifié",
"customFieldDeleted" : "Champ personnalisé supprimé",
"usableFields" : "Champ(s) utilisable(s)",
"noCustomFieldInfo" : "<b>Aucun champ personnalisé</b> n'est défini, sélectionner des éléments disponibles sur le <b>panneau de droite</b> afin de créer de nouveaux champs.",
"defaultValue" : "Valeur par défaut",
"valuesList" : "Liste des valeurs",
"addValue" : "Ajouter une valeur",
"orderValues" : "Trier les données",
"customFieldsTypesAvailable" : "Types de champs disponibles",
"typeValue" : "Saisisser une valeur",
"chooseDate" : "Choisisser une date",
"selectedValue" : "Valeur sélectionnée",
"choice" : "Choix",
}; };
...@@ -1107,5 +1107,21 @@ export const LANG_NL = { ...@@ -1107,5 +1107,21 @@ export const LANG_NL = {
"dateInput" : "Date input", //_TO_TRANSLATE "dateInput" : "Date input", //_TO_TRANSLATE
"radioInput" : "Radio input", //_TO_TRANSLATE "radioInput" : "Radio input", //_TO_TRANSLATE
"checkboxInput" : "Checbox input", //_TO_TRANSLATE "checkboxInput" : "Checbox input", //_TO_TRANSLATE
"customFieldAlreadyExists" : "Custom fields already exists with this name" //_TO_TRANSLATE "customFieldAlreadyExists" : "Custom fields already exists with this name", //_TO_TRANSLATE
"newField" : "New field", //_TO_TRANSLATE
"newValue" : "New value", //_TO_TRANSLATE
"customFieldAdded" : "Custom field added", //_TO_TRANSLATE
"customFieldUpdated" : "Custom field updated", //_TO_TRANSLATE
"customFieldDeleted" : "Custom field deleted", //_TO_TRANSLATE
"usableFields" : "Usable field(s)", //_TO_TRANSLATE
"noCustomFieldInfo" : "<b>No custom field</b> available, choose avaiblable custom fields types on <b>right panel</b> in order to create new custom fields.", //_TO_TRANSLATE
"defaultValue" : "Default value", //_TO_TRANSLATE
"valuesList" : "List of values", //_TO_TRANSLATE
"addValue" : "Add a value", //_TO_TRANSLATE
"orderValues" : "Order values", //_TO_TRANSLATE
"customFieldsTypesAvailable" : "Custom fields types available", //_TO_TRANSLATE
"typeValue" : "Type a value", //_TO_TRANSLATE
"chooseDate" : "Choose a date", //_TO_TRANSLATE
"selectedValue" : "Selected value", //_TO_TRANSLATE
"choice" : "Choice", //_TO_TRANSLATE
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment