From b8fa7946bf2702bd62f826c928596094fb787aed Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Fri, 13 Sep 2019 16:50:55 +0200
Subject: [PATCH] FEAT #11270 TIME 3 add values number + remove default_value

---
 ...ustom-fields-administration.component.html | 34 +++----
 ...ustom-fields-administration.component.scss | 98 +------------------
 .../custom-fields-administration.component.ts |  8 +-
 3 files changed, 24 insertions(+), 116 deletions(-)

diff --git a/src/frontend/app/administration/customField/custom-fields-administration.component.html b/src/frontend/app/administration/customField/custom-fields-administration.component.html
index 73a0d4e4731..0b0d03609e9 100644
--- a/src/frontend/app/administration/customField/custom-fields-administration.component.html
+++ b/src/frontend/app/administration/customField/custom-fields-administration.component.html
@@ -26,24 +26,17 @@
                                         {{lang[custom.type + 'Input']}}
                                     </mat-panel-description>
                                 </mat-expansion-panel-header>
-                                <div class="col-md-6">
+                                <div class="col-md-12">
                                     <mat-form-field>
                                         <input matInput name="label" [(ngModel)]="custom.label"
                                             [placeholder]="lang.label" [value]="custom.label">
                                     </mat-form-field>
                                 </div>
-                                <div class="col-md-6">
-                                    <mat-form-field>
-                                        <input matInput name="default_value" [placeholder]="lang.defaultValue"
-                                            [(ngModel)]="custom.default_value" [value]="custom.default_value"
-                                            [disabled]="custom.type === 'date'">
-                                    </mat-form-field>
-                                </div>
                                 <div class="col-md-12"
                                     *ngIf="['select', 'radio', 'checkbox'].indexOf(custom.type) > -1">
                                     <mat-expansion-panel class="customFieldValues" opened>
                                         <mat-expansion-panel-header>
-                                            <mat-panel-title>
+                                            <mat-panel-title [matBadge]="custom.values.length" matBadgeSize="small">
                                                 {{lang.valuesList}}
                                             </mat-panel-title>
                                         </mat-expansion-panel-header>
@@ -62,8 +55,10 @@
                                             </div>
                                         </div>
                                         <div class="col-md-12">
-                                            <mat-form-field *ngFor="let value of custom.values;let i=index;" floatLabel="never">
-                                                <input matInput [(ngModel)]="value.label" [placeholder]="this.lang.newValue">
+                                            <mat-form-field *ngFor="let value of custom.values;let i=index;"
+                                                floatLabel="never">
+                                                <input matInput [(ngModel)]="value.label"
+                                                    [placeholder]="this.lang.newValue">
                                                 <button color="warn" mat-icon-button matSuffix [title]="lang.delete"
                                                     (click)="removeValue(custom, i)">
                                                     <mat-icon class="fa fa-trash"></mat-icon>
@@ -84,7 +79,6 @@
                     </mat-tab>
                 </mat-tab-group>
             </mat-card>
-
         </mat-sidenav-content>
         <mat-sidenav #snav2 [mode]="appService.getViewMode() ? 'over' : 'side'"
             [fixedInViewport]="appService.getViewMode()" fixedTopGap="56" position='end' opened
@@ -93,7 +87,8 @@
                 <mat-tab [label]="lang.customFieldsTypesAvailable">
                     <div class="customFieldsTypesItem" *ngFor="let customField of customFieldsTypes">
                         <div class="addCustomFieldTypeContainer">
-                            <button mat-icon-button color="primary" (click)="addCustomField(customField)" [title]="lang.add">
+                            <button mat-icon-button color="primary" (click)="addCustomField(customField)"
+                                [title]="lang.add">
                                 <mat-icon class="fas fa-plus-circle fa-2x"></mat-icon>
                             </button>
                         </div>
@@ -101,13 +96,13 @@
                             <div style="color: rgba(0,0,0,0.54);">{{customField.label}} :</div>
                             <ng-container *ngIf="customField.type === 'string'">
                                 <mat-form-field class="input-form" floatLabel="never">
-                                    <textarea matInput [placeholder]="lang.typeValue" matTextareaAutosize
-                                        matAutosizeMinRows="1" cdkAutosizeMaxRows="6"></textarea>
+                                    <textarea matInput [placeholder]="lang[customField.type + 'Input']"
+                                        matTextareaAutosize matAutosizeMinRows="1" cdkAutosizeMaxRows="6"></textarea>
                                 </mat-form-field>
                             </ng-container>
                             <ng-container *ngIf="customField.type === 'select'">
                                 <mat-form-field class="input-form" floatLabel="never">
-                                    <mat-select [placeholder]="lang.chooseValue">
+                                    <mat-select [placeholder]="lang[customField.type + 'Input']">
                                         <mat-option *ngFor="let sample of sampleIncrement" [value]="sample">
                                             {{lang.choice}} {{sample}}
                                         </mat-option>
@@ -116,8 +111,8 @@
                             </ng-container>
                             <ng-container *ngIf="customField.type === 'date'">
                                 <mat-form-field class="input-form" floatLabel="never">
-                                    <input matInput [matDatepicker]="picker" [placeholder]="lang.chooseDate"
-                                        (click)="picker.open()">
+                                    <input matInput [matDatepicker]="picker"
+                                        [placeholder]="lang[customField.type + 'Input']" (click)="picker.open()">
                                     <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
                                     <mat-datepicker #picker></mat-datepicker>
                                 </mat-form-field>
@@ -132,7 +127,8 @@
                             <ng-container *ngIf="customField.type === 'checkbox'">
                                 <div class="input-form checkbox-form">
                                     <mat-selection-list #shoes class="div-list">
-                                        <mat-list-option *ngFor="let sample of sampleIncrement" [value]="sample" checkboxPosition="before">
+                                        <mat-list-option *ngFor="let sample of sampleIncrement" [value]="sample"
+                                            checkboxPosition="before">
                                             {{lang.choice}} {{sample}}
                                         </mat-list-option>
                                     </mat-selection-list>
diff --git a/src/frontend/app/administration/customField/custom-fields-administration.component.scss b/src/frontend/app/administration/customField/custom-fields-administration.component.scss
index 8f1da8c9026..d6620aca7fd 100644
--- a/src/frontend/app/administration/customField/custom-fields-administration.component.scss
+++ b/src/frontend/app/administration/customField/custom-fields-administration.component.scss
@@ -5,100 +5,6 @@
     padding-bottom: 10px;
 }
 
-.div-list {
-    padding: 0px;
-    max-height: 150px;
-    overflow: auto;
-}
-
-.input-form {
-    color: #666;
-    width: 500px;
-
-    button {
-        font-size: 30px;
-    }
-
-    .mat-input-element {
-        color: $primary;
-        padding-left: 20px;
-    }
-
-    input {
-        padding-left: 20px;
-    }
-
-    ::ng-deep.mat-select-value-text {
-        padding-left: 20px;
-        color: $primary;
-    }
-
-    ::ng-deep.mat-form-field-label {
-        left: 20px;
-    }
-
-    ::ng-deep.mat-form-field-infix {
-        padding-bottom: 15px;
-    }
-
-    ::ng-deep.mat-form-field-flex {
-        background: white;
-        border-radius: 30px;
-        border: solid 1px $primary;
-    }
-
-    ::ng-deep .mat-form-field-underline {
-        display: none;
-    }
-
-    ::ng-deep.mat-form-field-suffix {
-        margin-right: 20px;
-    }
-
-    ::ng-deep.mat-select-arrow-wrapper {
-        padding-right: 20px;
-    }
-
-    ::ng-deep.mat-list-option {
-        color: rgba(0, 0, 0, 0.54);
-    }
-
-    textarea.cdk-textarea-autosize-measuring {
-        padding: 4px 0 !important;
-    }
-}
-
-.checkbox-form {
-    width: 100%;
-    padding: 0px;
-    border: solid 1px $primary;
-    border-radius: 30px;
-    overflow: hidden;
-}
-
-.checkbox-selected-list {
-    margin-top: 10px;
-    display: flex;
-    justify-content: center;
-
-    ::ng-deep.mat-chip-list-wrapper {
-        justify-content: center;
-    }
-}
-
-.radio-form {
-    display: flex;
-
-    .mat-radio-button {
-        flex: 1;
-
-        ::ng-deep.mat-radio-label-content {
-            font-weight: normal;
-            color: rgba(0, 0, 0, 0.54);
-        }
-    }
-
-}
 
 .customFielsdPanel {
     padding-left: 0px;
@@ -154,4 +60,8 @@
    display:flex;
    padding-top: 10px;
    padding-bottom: 10px;
+}
+
+::ng-deep.mat-badge-content {
+    top: 2px !important;
 }
\ No newline at end of file
diff --git a/src/frontend/app/administration/customField/custom-fields-administration.component.ts b/src/frontend/app/administration/customField/custom-fields-administration.component.ts
index 30de1d3a441..a2f0b5c66e5 100644
--- a/src/frontend/app/administration/customField/custom-fields-administration.component.ts
+++ b/src/frontend/app/administration/customField/custom-fields-administration.component.ts
@@ -15,7 +15,10 @@ declare function $j(selector: any): any;
 
 @Component({
     templateUrl: "custom-fields-administration.component.html",
-    styleUrls: ['custom-fields-administration.component.scss'],
+    styleUrls: [
+        'custom-fields-administration.component.scss', 
+        '../../indexation/indexing-form/indexing-form.component.scss'
+    ],
     providers: [NotificationService, AppService, SortPipe]
 })
 
@@ -113,8 +116,7 @@ export class CustomFieldsAdministrationComponent implements OnInit {
                 newCustomField = {
                     label: this.lang.newField + ' ' + this.incrementCreation,
                     type: customFieldType.type,
-                    values: [],
-                    default_value: ''
+                    values: []
                 }
             }),
             exhaustMap((data) => this.http.post('../../rest/customFields', newCustomField)),
-- 
GitLab