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
Show more breadcrumbs
Cassiopée
nghyd
Commits
c8938b34
Commit
c8938b34
authored
5 years ago
by
mathias.chouet
Browse files
Options
Downloads
Patches
Plain Diff
Fix
#269
- PAB: remove multiple elements at a time
parent
57a0c5e3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/components/pab-table/pab-table.component.ts
+80
-10
80 additions, 10 deletions
src/app/components/pab-table/pab-table.component.ts
src/locale/messages.en.json
+3
-0
3 additions, 0 deletions
src/locale/messages.en.json
src/locale/messages.fr.json
+3
-0
3 additions, 0 deletions
src/locale/messages.fr.json
with
86 additions
and
10 deletions
src/app/components/pab-table/pab-table.component.ts
+
80
−
10
View file @
c8938b34
...
...
@@ -878,11 +878,52 @@ export class PabTableComponent implements AfterViewInit, OnInit {
}
public
get
enableRemoveButton
()
{
let
containsDownwall
=
false
;
let
containsOrphanNub
=
false
;
let
tooFewDevices
=
false
;
let
wallsCount
=
0
;
const
devicesCountById
=
{};
const
deletedWallsUids
=
[];
for
(
const
se
of
this
.
selectedItems
)
{
if
(
se
instanceof
Structure
)
{
// device
if
(
devicesCountById
[
se
.
parent
.
uid
]
===
undefined
)
{
devicesCountById
[
se
.
parent
.
uid
]
=
0
;
}
devicesCountById
[
se
.
parent
.
uid
]
++
;
}
else
{
// wall
wallsCount
++
;
deletedWallsUids
.
push
(
se
.
uid
);
}
if
(
se
instanceof
CloisonAval
)
{
containsDownwall
=
true
;
// cannot remove downwall
}
if
(
!
se
.
parent
)
{
containsOrphanNub
=
true
;
// not supposed to happen but who knows
}
}
// at least one device must remain in each basin, unless this basin is removed too
for
(
const
structureId
in
devicesCountById
)
{
if
(
!
deletedWallsUids
.
includes
(
structureId
))
{
let
wall
:
Nub
;
if
(
this
.
model
.
downWall
.
uid
===
structureId
)
{
wall
=
this
.
model
.
downWall
;
}
else
{
wall
=
this
.
model
.
getChild
(
structureId
);
}
if
(
wall
.
getChildren
().
length
<=
devicesCountById
[
structureId
])
{
tooFewDevices
=
true
;
}
}
}
return
(
this
.
selectedItems
.
length
===
1
&&
!
(
this
.
selectedItem
instanceof
CloisonAval
)
// exclude downwall
&&
this
.
selectedItem
.
parent
&&
this
.
selectedItem
.
parent
.
getChildren
().
length
>
1
this
.
selectedItems
.
length
>
0
&&
wallsCount
<
this
.
model
.
children
.
length
// at least one basin must remain
&&
!
containsDownwall
&&
!
containsOrphanNub
&&
!
tooFewDevices
);
}
...
...
@@ -1040,15 +1081,44 @@ export class PabTableComponent implements AfterViewInit, OnInit {
}
public
onRemoveClick
()
{
const
pos
=
this
.
selectedItem
.
findPositionInParent
()
+
1
;
this
.
selectedItem
.
parent
.
deleteChild
(
this
.
selectedItem
.
findPositionInParent
());
if
(
this
.
selectedItem
instanceof
Structure
)
{
this
.
notifService
.
notify
(
sprintf
(
this
.
i18nService
.
localizeText
(
"
INFO_DEVICE_REMOVED
"
),
pos
));
}
else
{
this
.
notifService
.
notify
(
sprintf
(
this
.
i18nService
.
localizeText
(
"
INFO_WALL_REMOVED
"
),
pos
));
let
wallsCount
=
0
;
let
devicesCount
=
0
;
const
deletedWallsUids
=
[];
// first pass: gather deleted structures UIDs
for
(
const
se
of
this
.
selectedItems
)
{
if
(
!
(
se
instanceof
Structure
))
{
wallsCount
++
;
deletedWallsUids
.
push
(
se
.
uid
);
}
}
// second pass: remove
for
(
const
se
of
this
.
selectedItems
)
{
if
(
se
instanceof
Structure
)
{
// device
// do not remove device if parent structure is to be removed too
if
(
!
deletedWallsUids
.
includes
(
se
.
parent
.
uid
))
{
se
.
parent
.
deleteChild
(
se
.
findPositionInParent
());
devicesCount
++
;
}
}
else
{
// remove wall
se
.
parent
.
deleteChild
(
se
.
findPositionInParent
());
}
}
this
.
selectedItems
=
[];
this
.
refresh
();
// notify
let
msg
:
string
;
if
(
wallsCount
===
0
)
{
msg
=
sprintf
(
this
.
i18nService
.
localizeText
(
"
INFO_DEVICES_REMOVED
"
),
devicesCount
);
}
else
if
(
devicesCount
===
0
)
{
msg
=
sprintf
(
this
.
i18nService
.
localizeText
(
"
INFO_WALLS_REMOVED
"
),
wallsCount
);
}
else
{
msg
=
sprintf
(
this
.
i18nService
.
localizeText
(
"
INFO_WALLS_AND_DEVICES_REMOVED
"
),
wallsCount
,
devicesCount
);
}
this
.
notifService
.
notify
(
msg
);
}
public
get
uitextAdd
():
string
{
...
...
This diff is collapsed.
Click to expand it.
src/locale/messages.en.json
+
3
−
0
View file @
c8938b34
...
...
@@ -122,6 +122,7 @@
"INFO_DEVICE_COPIED_N_TIMES"
:
"Device #%s copied %s times"
,
"INFO_DEVICE_MOVED"
:
"Device #%s moved"
,
"INFO_DEVICE_REMOVED"
:
"Device #%s removed"
,
"INFO_DEVICES_REMOVED"
:
"%s device(s) removed"
,
"INFO_FIELDSET_ADD"
:
"Add"
,
"INFO_FIELDSET_COPY"
:
"Copy"
,
"INFO_FIELDSET_REMOVE"
:
"Remove"
,
...
...
@@ -135,6 +136,8 @@
"INFO_WALL_COPIED_N_TIMES"
:
"Wall #%s copied %s times"
,
"INFO_WALL_MOVED"
:
"Wall #%s moved"
,
"INFO_WALL_REMOVED"
:
"Wall #%s removed"
,
"INFO_WALLS_AND_DEVICES_REMOVED"
:
"%s wall(s) and %s device(s) removed"
,
"INFO_WALLS_REMOVED"
:
"%s wall(s) removed"
,
"INFO_LECHAPTCALMON_TITRE_COURT"
:
"Lechapt-C."
,
"INFO_LECHAPTCALMON_TITRE"
:
"Lechapt-Calmon"
,
"INFO_LIB_LENGTHS"
:
"Every length"
,
...
...
This diff is collapsed.
Click to expand it.
src/locale/messages.fr.json
+
3
−
0
View file @
c8938b34
...
...
@@ -122,6 +122,7 @@
"INFO_DEVICE_COPIED_N_TIMES"
:
"Ouvrage n°%s copié %s fois"
,
"INFO_DEVICE_MOVED"
:
"Ouvrage n°%s déplacé"
,
"INFO_DEVICE_REMOVED"
:
"Ouvrage n°%s supprimé"
,
"INFO_DEVICES_REMOVED"
:
"%s ouvrage(s) supprimé(s)"
,
"INFO_FIELDSET_ADD"
:
"Ajouter"
,
"INFO_FIELDSET_COPY"
:
"Copier"
,
"INFO_FIELDSET_REMOVE"
:
"Supprimer"
,
...
...
@@ -135,6 +136,8 @@
"INFO_WALL_COPIED_N_TIMES"
:
"Cloison n°%s copiée %s fois"
,
"INFO_WALL_MOVED"
:
"Cloison n°%s déplacée"
,
"INFO_WALL_REMOVED"
:
"Cloison n°%s supprimée"
,
"INFO_WALLS_AND_DEVICES_REMOVED"
:
"%s cloison(s) et %s ouvrage(s) supprimé(s)"
,
"INFO_WALLS_REMOVED"
:
"%s cloison(s) supprimée(s)"
,
"INFO_LECHAPTCALMON_TITRE_COURT"
:
"Lechapt-C."
,
"INFO_LECHAPTCALMON_TITRE"
:
"Lechapt-Calmon"
,
"INFO_LIB_LENGTHS"
:
"Toutes les longueurs"
,
...
...
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