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
8b2f6748
Commit
8b2f6748
authored
5 years ago
by
mathias.chouet
Browse files
Options
Downloads
Patches
Plain Diff
PAB : implemented shift+click on input data table
parent
fdd14802
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!49
Resolve "Ajout du module de calcul d'une passe à bassins"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/components/pab-table/pab-table.component.ts
+86
-9
86 additions, 9 deletions
src/app/components/pab-table/pab-table.component.ts
with
86 additions
and
9 deletions
src/app/components/pab-table/pab-table.component.ts
+
86
−
9
View file @
8b2f6748
...
...
@@ -246,8 +246,70 @@ export class PabTableComponent implements AfterViewInit, OnInit {
&&
!
this
.
hasModel
(
cell
)
// editable cells listen to the click event for edition only
)
{
if
(
$event
.
shiftKey
&&
cell
!==
this
.
latestClickedCell
)
{
// shift + click
// @TODO interpopolate from this.latestClickedCell to this one
console
.
log
(
"
shift + click
"
);
// interpolate from this.latestClickedCell to this one
if
(
!
Array
.
isArray
(
cell
.
selectable
))
{
// multiselectable cells are not managed
const
wallsUIDs
=
this
.
getSortedWallsUIDs
();
let
posOld
:
number
;
let
posNew
:
number
;
// find positions depending on types, and only if types are equal
if
(
cell
.
selectable
instanceof
ParallelStructure
)
{
if
(
this
.
latestClickedCell
.
selectable
instanceof
ParallelStructure
)
{
// interpolate walls
posOld
=
wallsUIDs
.
indexOf
(
this
.
latestClickedCell
.
selectable
.
uid
);
posNew
=
wallsUIDs
.
indexOf
(
cell
.
selectable
.
uid
);
if
(
posOld
!==
posNew
)
{
if
(
posOld
>
posNew
)
{
// invert order
[
posOld
,
posNew
]
=
[
posNew
,
posOld
];
}
// go
for
(
let
i
=
posOld
;
i
<=
posNew
;
i
++
)
{
if
(
i
<
this
.
model
.
children
.
length
)
{
// push regular wall
this
.
selectedItems
.
push
(
this
.
model
.
children
[
i
]);
}
else
{
// push downwall
this
.
selectedItems
.
push
(
this
.
model
.
downWall
);
}
this
.
latestClickedCell
=
cell
;
}
}
}
}
else
if
(
cell
.
selectable
instanceof
Structure
)
{
if
(
this
.
latestClickedCell
.
selectable
instanceof
Structure
)
{
// accept interpolation only if both devices are on the same column
const
columnOld
=
this
.
latestClickedCell
.
selectable
.
findPositionInParent
();
const
columnNew
=
cell
.
selectable
.
findPositionInParent
();
if
(
columnOld
===
columnNew
)
{
// interpolate devices
posOld
=
wallsUIDs
.
indexOf
(
this
.
latestClickedCell
.
selectable
.
parent
.
uid
);
posNew
=
wallsUIDs
.
indexOf
(
cell
.
selectable
.
parent
.
uid
);
if
(
posOld
!==
posNew
)
{
if
(
posOld
>
posNew
)
{
// invert order
[
posOld
,
posNew
]
=
[
posNew
,
posOld
];
}
// go
for
(
let
i
=
posOld
;
i
<=
posNew
;
i
++
)
{
if
(
i
<
this
.
model
.
children
.
length
)
{
// push regular wall
this
.
selectedItems
.
push
(
this
.
model
.
children
[
i
].
structures
[
columnOld
]);
}
else
{
// push downwall
this
.
selectedItems
.
push
(
this
.
model
.
downWall
.
structures
[
columnOld
]);
}
}
this
.
latestClickedCell
=
cell
;
}
}
}
}
// clean selected items list (deduplicate, sort)
this
.
selectedItems
=
this
.
selectedItems
.
filter
(
(
item
,
index
)
=>
this
.
selectedItems
.
indexOf
(
item
)
===
index
// deduplicate
);
this
.
sortSelectedItems
();
}
}
else
if
(
$event
.
ctrlKey
// ctrl + click
...
...
@@ -272,6 +334,7 @@ export class PabTableComponent implements AfterViewInit, OnInit {
}
this
.
sortSelectedItems
();
}
this
.
latestClickedCell
=
cell
;
}
else
{
// just a click
if
(
this
.
isSelected
(
cell
))
{
...
...
@@ -285,12 +348,13 @@ export class PabTableComponent implements AfterViewInit, OnInit {
this
.
selectedItems
=
[
cell
.
selectable
];
}
}
this
.
latestClickedCell
=
cell
;
}
this
.
latestClickedCell
=
cell
;
// clean list
this
.
selectedItems
=
this
.
selectedItems
.
filter
(
e
=>
e
!==
undefined
);
this
.
clearSelection
();
$event
.
preventDefault
();
$event
.
stopPropagation
();
return
false
;
...
...
@@ -322,17 +386,30 @@ export class PabTableComponent implements AfterViewInit, OnInit {
this
.
refresh
();
}
/**
* Ensures that this.selectedItems elements are ordered according to
* the walls order in the PAB (important for interpolation)
*/
private
sortSelectedItems
()
{
// extract PAB walls order
/** Unselects all selected text (side-effect of shift+clicking) */
private
clearSelection
()
{
if
(
window
.
getSelection
)
{
const
sel
=
window
.
getSelection
();
sel
.
removeAllRanges
();
}
}
// extract PAB walls order
private
getSortedWallsUIDs
():
string
[]
{
const
wallsUIDs
:
string
[]
=
[];
for
(
const
c
of
this
.
pabTable
.
pab
.
children
)
{
wallsUIDs
.
push
(
c
.
uid
);
}
wallsUIDs
.
push
(
this
.
pabTable
.
pab
.
downWall
.
uid
);
return
wallsUIDs
;
}
/**
* Ensures that this.selectedItems elements are ordered according to
* the walls order in the PAB (important for interpolation)
*/
private
sortSelectedItems
()
{
const
wallsUIDs
=
this
.
getSortedWallsUIDs
();
// are items walls or devices ?
if
(
this
.
onlyWallsAreSelected
(
false
))
{
// 1. walls : order by uid, according to model
...
...
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