Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nghyd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
A compter du 1er avril, attention à vos pipelines :
Nouvelles limitations de Docker Hub
Show more breadcrumbs
Cassiopée
nghyd
Commits
bdde43bf
Commit
bdde43bf
authored
3 years ago
by
François Grand
Browse files
Options
Downloads
Patches
Plain Diff
fix: parallel structures: backup and restore parameters on device creation/cloning
refs
#480
parent
229c178e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!133
Release version 4.15.0
,
!119
Resolve "Mode "champs vides par défaut" : changer le type d'un ouvrage (ex: dans Cloisons) remplit les champs"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/components/fieldset-container/fieldset-container.component.ts
+9
-21
9 additions, 21 deletions
...onents/fieldset-container/fieldset-container.component.ts
src/app/formulaire/elements/fieldset.ts
+54
-2
54 additions, 2 deletions
src/app/formulaire/elements/fieldset.ts
with
63 additions
and
23 deletions
src/app/components/fieldset-container/fieldset-container.component.ts
+
9
−
21
View file @
bdde43bf
...
...
@@ -74,28 +74,16 @@ export class FieldsetContainerComponent implements DoCheck, AfterViewInit {
* Ajoute un nouveau sous-nub (Structure, PabCloisons, YAXN… selon le cas)
* dans un nouveau fieldset
*/
private
addSubNub
(
after
?:
FieldSet
,
clone
:
boolean
=
false
)
{
if
(
after
)
{
const
newFs
=
this
.
_container
.
addFromTemplate
(
0
,
after
.
indexAsKid
());
if
(
this
.
appSetupService
.
enableEmptyFieldsOnFormInit
&&
!
clone
)
{
newFs
.
emptyFields
();
}
if
(
clone
)
{
// replace in-place to change properties (overkill)
// @WTF why only those two ?
newFs
.
setPropValue
(
"
structureType
"
,
after
.
properties
.
getPropValue
(
"
structureType
"
));
newFs
.
setPropValue
(
"
loiDebit
"
,
after
.
properties
.
getPropValue
(
"
loiDebit
"
));
// copy param values
for
(
const
p
of
after
.
nub
.
prms
)
{
newFs
.
nub
.
getParameter
(
p
.
symbol
).
loadObjectRepresentation
(
p
.
objectRepresentation
());
}
}
}
else
{
const
newFs
=
this
.
_container
.
addFromTemplate
(
0
);
if
(
this
.
appSetupService
.
enableEmptyFieldsOnFormInit
&&
!
clone
)
{
newFs
.
emptyFields
();
}
private
addSubNub
(
after
:
FieldSet
,
clone
:
boolean
=
false
)
{
const
prms
=
after
.
backupParameters
();
const
newFs
=
this
.
_container
.
addFromTemplate
(
0
,
after
.
indexAsKid
());
if
(
clone
)
{
// replace in-place to change properties (overkill)
// @WTF why only those two ?
newFs
.
setPropValue
(
"
structureType
"
,
after
.
properties
.
getPropValue
(
"
structureType
"
));
newFs
.
setPropValue
(
"
loiDebit
"
,
after
.
properties
.
getPropValue
(
"
loiDebit
"
));
}
newFs
.
restoreParameters
(
prms
);
}
private
onFieldsetListChange
()
{
...
...
This diff is collapsed.
Click to expand it.
src/app/formulaire/elements/fieldset.ts
+
54
−
2
View file @
bdde43bf
...
...
@@ -15,6 +15,8 @@ import { FieldsetContainer } from "./fieldset-container";
import
{
SelectFieldCustom
}
from
"
./select-field-custom
"
;
import
{
FormulaireFixedVar
}
from
"
../definition/form-fixedvar
"
;
import
{
SelectEntry
}
from
"
./select-entry
"
;
import
{
FormulaireNode
}
from
"
./formulaire-node
"
;
import
{
ServiceFactory
}
from
"
app/services/service-factory
"
;
export
class
FieldSet
extends
FormulaireElement
implements
Observer
{
...
...
@@ -51,6 +53,50 @@ export class FieldSet extends FormulaireElement implements Observer {
this
.
kids
.
push
(
f
);
}
/**
* backup NgParameters kids
* @returns a list of object representation with sybol, value, modification flag
*/
public
backupParameters
():
any
[]
{
const
res
:
any
[]
=
[];
// for (const p of this.allFormElements) {
for
(
const
p
of
this
.
_kids
)
{
if
(
p
instanceof
NgParameter
)
{
res
.
push
(
p
.
objectRepresentation
());
}
}
return
res
;
}
/**
* restore NgParameters kids from backup list
* @param backup list of NgParameter object representation
* @see backupParameters
*/
public
restoreParameters
(
backup
:
any
[],
except
:
string
[]
=
FormulaireNode
.
NeverEmptyFields
)
{
// for (const p of this.allFormElements) {
for
(
const
p
of
this
.
_kids
)
{
if
(
p
instanceof
NgParameter
)
{
for
(
const
bp
of
backup
)
{
if
(
p
.
symbol
===
bp
.
prmDef
.
symbol
)
{
// if source parameter has been user modified, copy value
if
(
bp
.
modified
)
{
p
.
loadObjectRepresentation
(
bp
);
}
else
{
// can parameter be emptied ?
if
(
ServiceFactory
.
applicationSetupService
.
enableEmptyFieldsOnFormInit
&&
!
except
.
includes
(
bp
.
prmDef
.
symbol
))
{
p
.
resetValue
(
this
,
undefined
);
}
// else let parameter to default value
}
break
;
}
}
}
}
}
public
get
hasInputs
():
boolean
{
for
(
const
f
of
this
.
kids
)
{
if
(
f
instanceof
NgParameter
)
{
...
...
@@ -353,9 +399,12 @@ export class FieldSet extends FormulaireElement implements Observer {
});
}
}
else
{
// for all select fields known by the form, apply received value
// to associated property
if
(
this
.
parentForm
instanceof
FormulaireFixedVar
)
{
// backup parameters
const
oldParams
=
this
.
backupParameters
();
// for all select fields known by the form, apply received value
// to associated property
const
selectIds
=
this
.
parentForm
.
selectids
;
for
(
const
sId
of
selectIds
)
{
if
(
senderId
===
sId
)
{
...
...
@@ -372,6 +421,9 @@ export class FieldSet extends FormulaireElement implements Observer {
}
}
}
// restore parameters
this
.
restoreParameters
(
oldParams
,
FormulaireNode
.
NeverEmptyFields
);
}
}
break
;
// switch (data.action)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment