|
|
|
@ -3,6 +3,7 @@ import {opServicesModule} from '../../../angular-modules'; |
|
|
|
|
import {WPTableRowSelectionState, WorkPackageTableRow} from '../wp-table.interfaces'; |
|
|
|
|
import {WorkPackageResource} from '../../api/api-v3/hal-resources/work-package-resource.service'; |
|
|
|
|
import {InputState} from "reactivestates"; |
|
|
|
|
import {RenderedRow} from '../builders/primary-render-pass'; |
|
|
|
|
|
|
|
|
|
export class WorkPackageTableSelection { |
|
|
|
|
|
|
|
|
@ -23,11 +24,13 @@ export class WorkPackageTableSelection { |
|
|
|
|
/** |
|
|
|
|
* Select all work packages |
|
|
|
|
*/ |
|
|
|
|
public selectAll(rows: string[]) { |
|
|
|
|
public selectAll(rows: RenderedRow[]) { |
|
|
|
|
const state:WPTableRowSelectionState = this._emptyState; |
|
|
|
|
|
|
|
|
|
rows.forEach((workPackageId:string) => { |
|
|
|
|
state.selected[workPackageId] = true; |
|
|
|
|
rows.forEach((row) => { |
|
|
|
|
if (row.workPackageId) { |
|
|
|
|
state.selected[row.workPackageId] = true; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.selectionState.putValue(state); |
|
|
|
@ -109,12 +112,12 @@ export class WorkPackageTableSelection { |
|
|
|
|
/** |
|
|
|
|
* Override current selection with the given work package id. |
|
|
|
|
*/ |
|
|
|
|
public setSelection(row:WorkPackageTableRow) { |
|
|
|
|
public setSelection(wpId:string, position:number) { |
|
|
|
|
let state:WPTableRowSelectionState = { |
|
|
|
|
selected: {}, |
|
|
|
|
activeRowIndex: row.position |
|
|
|
|
activeRowIndex: position |
|
|
|
|
}; |
|
|
|
|
state.selected[row.workPackageId] = true; |
|
|
|
|
state.selected[wpId] = true; |
|
|
|
|
|
|
|
|
|
this.selectionState.putValue(state); |
|
|
|
|
} |
|
|
|
@ -123,21 +126,21 @@ export class WorkPackageTableSelection { |
|
|
|
|
* Select a number of rows from the current `activeRowIndex` |
|
|
|
|
* to the selected target. |
|
|
|
|
* (aka shift click expansion) |
|
|
|
|
* @param rows Current visible rows |
|
|
|
|
* @param selected Selection target |
|
|
|
|
*/ |
|
|
|
|
public setMultiSelectionFrom(rows:string[], selected:WorkPackageTableRow) { |
|
|
|
|
public setMultiSelectionFrom(rows:RenderedRow[], wpId:string, position:number) { |
|
|
|
|
let state = this.currentState; |
|
|
|
|
|
|
|
|
|
if (this.selectionCount === 0) { |
|
|
|
|
state.selected[selected.workPackageId] = true; |
|
|
|
|
state.activeRowIndex = selected.position; |
|
|
|
|
state.selected[wpId] = true; |
|
|
|
|
state.activeRowIndex = position; |
|
|
|
|
} else if (state.activeRowIndex !== null) { |
|
|
|
|
let start = Math.min(selected.position, state.activeRowIndex); |
|
|
|
|
let end = Math.max(selected.position, state.activeRowIndex); |
|
|
|
|
let start = Math.min(position, state.activeRowIndex); |
|
|
|
|
let end = Math.max(position, state.activeRowIndex); |
|
|
|
|
|
|
|
|
|
rows.forEach((workPackageId, i) => { |
|
|
|
|
state.selected[workPackageId] = i >= start && i <= end; |
|
|
|
|
rows.forEach((row, i) => { |
|
|
|
|
if (row.workPackageId) { |
|
|
|
|
state.selected[row.workPackageId] = i >= start && i <= end; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|