+
diff --git a/src/app/modules/shared/components/action-bar/action-bar.ts b/src/app/modules/shared/components/action-bar/action-bar.ts
index 506bed9..61df16b 100644
--- a/src/app/modules/shared/components/action-bar/action-bar.ts
+++ b/src/app/modules/shared/components/action-bar/action-bar.ts
@@ -1,4 +1,4 @@
-import {Component} from '@angular/core'
+import {Component, Input} from '@angular/core'
@Component({
selector: 'cre-action-group',
@@ -11,4 +11,6 @@ export class CreActionGroup {}
selector: 'cre-action-bar',
templateUrl: 'action-bar.html'
})
-export class CreActionBar {}
+export class CreActionBar {
+ @Input() reverse = false
+}
diff --git a/src/app/modules/shared/components/forms/buttons.ts b/src/app/modules/shared/components/forms/buttons.ts
new file mode 100644
index 0000000..0cebdc4
--- /dev/null
+++ b/src/app/modules/shared/components/forms/buttons.ts
@@ -0,0 +1,17 @@
+import {Component, EventEmitter, Input, Output} from '@angular/core';
+import {ICreForm} from './forms';
+
+@Component({
+ selector: 'cre-submit-button',
+ templateUrl: 'submit-button.html'
+})
+export class CreSubmitButton {
+ @Input() form: ICreForm
+ @Input() valid: boolean | null
+
+ @Output() submit = new EventEmitter
()
+
+ get disableButton(): boolean {
+ return !this.form || !(this.valid ?? this.form.valid)
+ }
+}
diff --git a/src/app/modules/shared/components/forms/forms.module.ts b/src/app/modules/shared/components/forms/forms.module.ts
index 2ee4a91..4e1a91c 100644
--- a/src/app/modules/shared/components/forms/forms.module.ts
+++ b/src/app/modules/shared/components/forms/forms.module.ts
@@ -1,28 +1,34 @@
import {NgModule} from '@angular/core'
-import {CreFormActions, CreFormComponent, CreFormContent, CreFormTitle} from './forms'
+import {CreFormActions, CreForm, CreFormContent, CreFormTitle} from './forms'
import {MatCardModule} from '@angular/material/card'
import {CommonModule} from '@angular/common'
import {MatButtonModule} from '@angular/material/button'
import {ReactiveFormsModule} from '@angular/forms'
+import {CreSubmitButton} from './buttons';
+import {CreButtonsModule} from '../buttons/buttons.module';
@NgModule({
declarations: [
- CreFormComponent,
+ CreForm,
CreFormTitle,
CreFormContent,
- CreFormActions
+ CreFormActions,
+ CreSubmitButton
],
exports: [
- CreFormComponent,
+ CreForm,
CreFormTitle,
CreFormContent,
- CreFormActions
+ CreFormActions,
+ CreSubmitButton
],
- imports: [
- MatCardModule,
- CommonModule,
- MatButtonModule,
- ReactiveFormsModule
- ]
+ imports: [
+ MatCardModule,
+ CommonModule,
+ MatButtonModule,
+ ReactiveFormsModule,
+ CreButtonsModule
+ ]
})
-export class CreFormsModule {}
+export class CreFormsModule {
+}
diff --git a/src/app/modules/shared/components/forms/forms.ts b/src/app/modules/shared/components/forms/forms.ts
index 98a556c..7619f15 100644
--- a/src/app/modules/shared/components/forms/forms.ts
+++ b/src/app/modules/shared/components/forms/forms.ts
@@ -1,6 +1,12 @@
import {Component, ContentChild, Directive, Input, OnInit, ViewEncapsulation} from '@angular/core'
import {FormBuilder, FormGroup} from '@angular/forms'
+export interface ICreForm {
+ form: FormGroup
+ valid: boolean
+ invalid: boolean
+}
+
@Directive({
selector: 'cre-form-title'
})
@@ -17,7 +23,6 @@ export class CreFormContent {
selector: 'cre-form-actions'
})
export class CreFormActions {
-
}
@Component({
@@ -26,7 +31,7 @@ export class CreFormActions {
styleUrls: ['forms.sass'],
encapsulation: ViewEncapsulation.None
})
-export class CreFormComponent implements OnInit {
+export class CreForm implements ICreForm, OnInit {
@ContentChild(CreFormActions) formActions: CreFormActions
@Input() formControls: { [key: string]: any }
@@ -45,6 +50,10 @@ export class CreFormComponent implements OnInit {
return !!this.formActions
}
+ get valid(): boolean {
+ return this.form && this.form.valid
+ }
+
get invalid(): boolean {
return !this.form || this.form.invalid
}
diff --git a/src/app/modules/shared/components/forms/submit-button.html b/src/app/modules/shared/components/forms/submit-button.html
new file mode 100644
index 0000000..8e9289a
--- /dev/null
+++ b/src/app/modules/shared/components/forms/submit-button.html
@@ -0,0 +1 @@
+Enregistrer
diff --git a/src/app/modules/shared/components/inputs/input.html b/src/app/modules/shared/components/inputs/input.html
index 7b5f60f..f58c818 100644
--- a/src/app/modules/shared/components/inputs/input.html
+++ b/src/app/modules/shared/components/inputs/input.html
@@ -5,7 +5,7 @@
@@ -14,7 +14,7 @@
diff --git a/src/app/modules/shared/components/inputs/inputs.ts b/src/app/modules/shared/components/inputs/inputs.ts
index fb038e9..74335cf 100644
--- a/src/app/modules/shared/components/inputs/inputs.ts
+++ b/src/app/modules/shared/components/inputs/inputs.ts
@@ -15,7 +15,7 @@ import {
} from '@angular/core'
import {AbstractControl, FormControl, ValidationErrors, ValidatorFn, Validators} from '@angular/forms'
import {COMMA, ENTER} from '@angular/cdk/keycodes'
-import {Observable, Subject} from 'rxjs'
+import {isObservable, Observable, Subject} from 'rxjs'
import {map, takeUntil} from 'rxjs/operators'
import {MatChipInputEvent} from '@angular/material/chips'
import {MatAutocomplete, MatAutocompleteSelectedEvent} from '@angular/material/autocomplete'
@@ -50,16 +50,16 @@ export class CreInputComponent extends _CreInputBase implements AfterViewInit {
@ViewChild('input') input: any
@ContentChild(TemplateRef) errors: TemplateRef
+ fieldRequired = true
+
ngAfterViewInit() {
const element = this.input.nativeElement
element.type = this.type
element.step = this.step.toString()
element.placeholder = this.placeholder
element.autocomplete = this.autocomplete ? 'on' : 'off'
- }
- get isFieldRequired(): boolean {
- return this.control ? this.control.validator && this.control.validator({} as AbstractControl)?.required : this.required
+ this.fieldRequired = this.control ? this.control.validator && this.control.validator({} as AbstractControl)?.required : this.required
}
}
@@ -400,7 +400,19 @@ export class CreSliderInputComponent {
templateUrl: 'select.html'
})
export class CreSelectComponent extends _CreInputBase {
- @Input() entries: Observable
+ @Input() entries: Observable | CreInputEntry[]
+
+ get entriesAreObservable(): boolean {
+ return isObservable(this.entries)
+ }
+
+ get arrayEntries(): CreInputEntry[] {
+ return this.entries as CreInputEntry[]
+ }
+
+ get observableEntries(): Observable {
+ return this.entries as Observable
+ }
}
export class CreInputEntry {
diff --git a/src/app/modules/shared/components/inputs/select.html b/src/app/modules/shared/components/inputs/select.html
index 6fd806b..e17b4a4 100644
--- a/src/app/modules/shared/components/inputs/select.html
+++ b/src/app/modules/shared/components/inputs/select.html
@@ -1,8 +1,17 @@
{{label}}
-
-
- {{entry.display || entry.value}}
-
+
+
+
+ {{entry.display || entry.value}}
+
+
+
+
+ {{entry.display || entry.value}}
+
+
diff --git a/src/app/modules/shared/model/material.model.ts b/src/app/modules/shared/model/material.model.ts
index 56187fd..5c31599 100644
--- a/src/app/modules/shared/model/material.model.ts
+++ b/src/app/modules/shared/model/material.model.ts
@@ -1,4 +1,4 @@
-import {MaterialType} from "./materialtype.model";
+import {MaterialType} from './materialtype.model';
import {openPdf} from '../utils/utils'
export class Material {
@@ -15,3 +15,25 @@ export class Material {
export function openSimdut(material: Material) {
openPdf(material.simdutUrl)
}
+
+export const materialComparator = (a: Material, b: Material): number => {
+ const aPrefixName = a.materialType.prefix.toLowerCase()
+ const bPrefixName = b.materialType.prefix.toLowerCase()
+
+ if (aPrefixName < bPrefixName) {
+ return -1
+ } else if (aPrefixName > bPrefixName) {
+ return 1
+ } else {
+ const aName = a.name.toLowerCase()
+ const bName = b.name.toLowerCase()
+
+ if (aName < bName) {
+ return -1
+ } else if (aName > bName) {
+ return 1
+ } else {
+ return 0
+ }
+ }
+}
diff --git a/src/app/modules/touch-up-kit/components/form.ts b/src/app/modules/touch-up-kit/components/form.ts
index 09c7248..5fa1a89 100644
--- a/src/app/modules/touch-up-kit/components/form.ts
+++ b/src/app/modules/touch-up-kit/components/form.ts
@@ -1,6 +1,6 @@
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'
import {chipListRequired, CreInputEntry, CreChipComboBoxComponent} from '../../shared/components/inputs/inputs'
-import {CreFormComponent} from '../../shared/components/forms/forms'
+import {CreForm} from '../../shared/components/forms/forms'
import {TouchUpKitProductEditor} from './product-editor'
import {FormControl, Validators} from '@angular/forms'
import {RecipeService} from '../../recipes/services/recipe.service'
@@ -18,7 +18,7 @@ import {map} from 'rxjs/operators'
export class TouchUpKitForm extends SubscribingComponent {
@ViewChild('finishInput') finishInput: CreChipComboBoxComponent
@ViewChild('materialInput') materialInput: CreChipComboBoxComponent
- @ViewChild(CreFormComponent) form: CreFormComponent
+ @ViewChild(CreForm) form: CreForm
@ViewChild(TouchUpKitProductEditor) contentEditor: TouchUpKitProductEditor
@Input() touchUpKit: TouchUpKit | null