Verified Commit 2ab76cdd authored by Alex ORLUC's avatar Alex ORLUC

FEAT #11270 TIME 2:30 addd var lang + end front admin custom fields

parent bba6b892
......@@ -132,4 +132,26 @@
display: flex;
align-items: 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 {
lang: any = LANG;
loading: boolean = false;
creationMode: any = false;
customFieldsTypes: any[] = [
{
......@@ -51,17 +50,13 @@ export class CustomFieldsAdministrationComponent implements OnInit {
type: 'checkbox'
}
]
customFields: any[] = [
{
id: 4,
label: 'Nouveau champ',
type: 'select',
values: [],
default_value: ''
}
];
customFields: any[] = [];
customFieldsClone: any[] = [];
incrementCreation: number = 1;
sampleIncrement: number[] = [1,2,3,4];
customFieldClone: any;
dialogRef: MatDialogRef<any>;
......@@ -85,18 +80,18 @@ export class CustomFieldsAdministrationComponent implements OnInit {
// TO FIX DATA BINDING SIMPLE ARRAY VALUES
map((data: any) => {
data.customFields.forEach((element: any) => {
if (element.values != null) {
element.values = element.values.map((info: any) => {
return {
label: info
}
});
}
element.values = element.values.map((info: any) => {
return {
label: info
}
});
});
return data;
}),
tap((data: any) => {
this.customFields = data.customFields;
this.customFieldsClone = JSON.parse(JSON.stringify(this.customFields));
}),
finalize(() => this.loading = false),
catchError((err: any) => {
......@@ -116,7 +111,7 @@ export class CustomFieldsAdministrationComponent implements OnInit {
filter((data: string) => data === 'ok'),
tap(() => {
newCustomField = {
label: 'Nouveau champ',
label: this.lang.newField + ' ' + this.incrementCreation,
type: customFieldType.type,
values: [],
default_value: ''
......@@ -127,6 +122,7 @@ export class CustomFieldsAdministrationComponent implements OnInit {
newCustomField.id = data.customFieldId
this.customFields.push(newCustomField);
this.notify.success(this.lang.customFieldAdded);
this.incrementCreation++;
}),
catchError((err: any) => {
this.notify.handleErrors(err);
......@@ -138,7 +134,7 @@ export class CustomFieldsAdministrationComponent implements OnInit {
addValue(indexCustom: number) {
this.customFields[indexCustom].values.push(
{
label: 'Nouvelle donnée'
label: this.lang.newValue
}
);
}
......@@ -152,8 +148,10 @@ export class CustomFieldsAdministrationComponent implements OnInit {
this.dialogRef.afterClosed().pipe(
filter((data: string) => data === 'ok'),
exhaustMap(() => this.http.delete('../../rest/customFields/' + this.customFields[indexCustom].id)),
tap(() => {
this.customFields.splice(indexCustom, 1);
this.notify.success(this.lang.customFieldDeleted);
}),
catchError((err: any) => {
this.notify.handleErrors(err);
......@@ -162,16 +160,16 @@ export class CustomFieldsAdministrationComponent implements OnInit {
).subscribe();
}
updateCustomField(customField: any) {
updateCustomField(customField: any, indexCustom: number) {
// TO FIX DATA BINDING SIMPLE ARRAY VALUES
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)
this.http.put('../../rest/customFields/' + customField.id, customFieldToUpdate).pipe(
tap(() => {
this.customFieldsClone[indexCustom] = customField;
this.notify.success(this.lang.customFieldUpdated);
}),
catchError((err: any) => {
......@@ -185,13 +183,8 @@ export class CustomFieldsAdministrationComponent implements OnInit {
customField.values = this.sortPipe.transform(customField.values, 'label');
}
initCustomFieldCheck(customField: any) {
console.log('init');
this.customFieldClone = JSON.parse(JSON.stringify(customField));
}
isModified(customField: any) {
if (JSON.stringify(customField) === JSON.stringify(this.customFieldClone)) {
isModified(customField: any, indexCustomField: number) {
if (JSON.stringify(customField) === JSON.stringify(this.customFieldsClone[indexCustomField])) {
return true;
} else {
return false;
......
......@@ -1081,4 +1081,20 @@ export const LANG_EN = {
"dateInput" : "Date input",
"radioInput" : "Radio input",
"checkboxInput" : "Checbox input",
"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,4 +1118,20 @@ export const LANG_FR = {
"dateInput" : "Champ date",
"radioInput" : "Liste à choix unique",
"checkboxInput" : "Liste à choix multiple",
"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,4 +1107,20 @@ export const LANG_NL = {
"dateInput" : "Date input", //_TO_TRANSLATE
"radioInput" : "Radio input", //_TO_TRANSLATE
"checkboxInput" : "Checbox input", //_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