Skip to content
Snippets Groups Projects
Commit 113d60ea authored by mathias.chouet's avatar mathias.chouet
Browse files

Fix #196

parent d256b24c
No related branches found
No related tags found
No related merge requests found
......@@ -3,9 +3,18 @@
{{ title }}
</mat-card-title>
<div *ngIf="showButtons" class="hyd-window-btns">
<mat-select id="add-many-children" [(value)]="childrenToAdd">
<mat-option *ngFor="let i of addManyOptionsList" [value]="i">
{{ i }}
</mat-option>
</mat-select>
<button type="button" mat-icon-button (click)="onAddClick()" class="add-structure">
<mat-icon>add_box</mat-icon>
</button>
<button type="button" mat-icon-button (click)="onCopyClick()" class="copy-structure">
<mat-icon>content_copy</mat-icon>
</button>
|
<button type="button" mat-icon-button [disabled]="! enableRemoveButton" (click)="onRemoveClick()">
<mat-icon>delete</mat-icon>
</button>
......
......@@ -73,6 +73,12 @@ mat-card-actions {
margin-right: 0;
transform: scale(1);
}
&.copy-structure {
mat-icon {
transform: scale(0.9); // this one is slightly bigger
}
}
}
}
}
......@@ -82,3 +88,25 @@ mat-card-actions {
}
}
}
.copy-structure {
> mat-icon {
transform: scale(0.9);
}
}
#add-many-children {
width: 3em;
::ng-deep .mat-select-value, ::ng-deep .mat-select-arrow {
color: #fff !important;
}
::ng-deep .mat-form-field-infix {
border-bottom: 2px solid #fff !important;
}
/* ::ng-deep .mat-focused .mat-form-field-underline .mat-form-field-ripple {
background: none;
} */
}
......@@ -18,6 +18,9 @@ import { FieldsetContainer } from "../../formulaire/fieldset-container";
})
export class FieldSetComponent implements DoCheck {
/** number of children to add when clicking "add" or "clone" button */
public childrenToAdd = 1;
@Input()
private set fieldSet(fs: FieldSet) {
this._fieldSet = fs;
......@@ -27,9 +30,9 @@ export class FieldSetComponent implements DoCheck {
return this._fieldSet.kids;
}
/* public set fieldsetNumber(n: number) {
this._fieldSet.labelNumber = n;
} */
public get addManyOptionsList() {
return Array(20).fill(0).map((value, index) => index + 1);
}
public get title(): string {
if (! this._fieldSet) {
......@@ -316,7 +319,26 @@ export class FieldSetComponent implements DoCheck {
* clic sur le bouton ajouter
*/
private onAddClick() {
this.addFieldset.emit(this._fieldSet);
for (let i = 0; i < this.childrenToAdd; i++) {
this.addFieldset.emit({
fs: this._fieldSet,
clone: false
});
}
this.childrenToAdd = 1; // reinit to avoid confusion
}
/**
* clic sur le bouton copier
*/
private onCopyClick() {
for (let i = 0; i < this.childrenToAdd; i++) {
this.addFieldset.emit({
fs: this._fieldSet,
clone: true
});
}
this.childrenToAdd = 1; // reinit to avoid confusion
}
/**
......
......@@ -68,22 +68,24 @@ export class FieldsetContainerComponent implements DoCheck, AfterViewInit {
* Ajoute un nouveau sous-nub (Structure, PabCloisons selon le cas)
* dans un nouveau fieldset
*/
private addSubNub(after?: FieldSet) {
private addSubNub(after?: FieldSet, clone: boolean = false) {
if (after) {
this._container.addFromTemplate(0, after.indexAsKid());
const newFs = this._container.addFromTemplate(0, after.indexAsKid());
if (clone) {
// replace in-place to change properties (overkill)
newFs.setPropValue("structureType", after.properties.getPropValue("structureType"));
newFs.setPropValue("loiDebit", after.properties.getPropValue("loiDebit"));
// after.nub.properties
for (const p of after.nub.prms) {
newFs.nub.getParameter(p.symbol).singleValue = p.singleValue;
}
}
} else {
this._container.addFromTemplate(0);
}
}
private onFieldsetListChange() {
// renumérotation
/* let n = 1;
this._fieldsetComponents.forEach(fsc => {
fsc.fieldsetNumber = n;
n++;
}
); */
}
public ngAfterViewInit() {
......@@ -164,8 +166,8 @@ export class FieldsetContainerComponent implements DoCheck, AfterViewInit {
/**
* réception d'un événement de demande d'ajout d'un FieldSet
*/
private onAddFieldset(fs: FieldSet) {
this.addSubNub(fs);
private onAddFieldset(evt: { fs: FieldSet, clone: boolean }) {
this.addSubNub(evt.fs, evt.clone);
}
/**
......
......@@ -64,7 +64,9 @@ export class FormulaireParallelStructure extends FormulaireBase {
}
/**
* Replaces the current Nub in the current calculator module, with a new one built with properties "params"
* Replaces the geiven Structure sn in the current calculator module,
* with a new one built with properties "params"
* @param sn Structure to replace
* @param params properties to build the new Nub (calcType, loiDebit...)
*/
protected replaceNub(sn: Structure, params: Props): Nub {
......
......@@ -47,7 +47,6 @@ export class FieldSet extends FormulaireElement implements Observer {
public setNub(sn: Nub, update: boolean = true) {
this._nub = sn;
this.setParentNubForAllFields();
// this._props.setProps(sn.properties || new Props({}), this);
if (update) {
this.updateFields();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment