|
|
|
@ -10,7 +10,10 @@ import { |
|
|
|
|
import { uiStateLinkClass } from 'core-app/features/work-packages/components/wp-fast-table/builders/ui-state-link-builder'; |
|
|
|
|
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service'; |
|
|
|
|
import { Highlighting } from 'core-app/features/work-packages/components/wp-fast-table/builders/highlighting/highlighting.functions'; |
|
|
|
|
import { StateService } from '@uirouter/core'; |
|
|
|
|
import { |
|
|
|
|
StateService, |
|
|
|
|
UIRouterGlobals, |
|
|
|
|
} from '@uirouter/core'; |
|
|
|
|
import { WorkPackageViewSelectionService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-selection.service'; |
|
|
|
|
import { WorkPackageCardViewService } from 'core-app/features/work-packages/components/wp-card-view/services/wp-card-view.service'; |
|
|
|
|
import { I18nService } from 'core-app/core/i18n/i18n.service'; |
|
|
|
@ -23,6 +26,8 @@ import { isClickedWithModifier } from 'core-app/shared/helpers/link-handling/lin |
|
|
|
|
import isNewResource from 'core-app/features/hal/helpers/is-new-resource'; |
|
|
|
|
import { TimezoneService } from 'core-app/core/datetime/timezone.service'; |
|
|
|
|
import { StatusResource } from 'core-app/features/hal/resources/status-resource'; |
|
|
|
|
import { combineLatest } from 'rxjs'; |
|
|
|
|
import { map } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'wp-single-card', |
|
|
|
@ -33,6 +38,8 @@ import { StatusResource } from 'core-app/features/hal/resources/status-resource' |
|
|
|
|
export class WorkPackageSingleCardComponent extends UntilDestroyedMixin implements OnInit { |
|
|
|
|
@Input() public workPackage:WorkPackageResource; |
|
|
|
|
|
|
|
|
|
@Input() public selectedWhenOpen = false; |
|
|
|
|
|
|
|
|
|
@Input() public showInfoButton = false; |
|
|
|
|
|
|
|
|
|
@Input() public showStatusButton = true; |
|
|
|
@ -65,6 +72,8 @@ export class WorkPackageSingleCardComponent extends UntilDestroyedMixin implemen |
|
|
|
|
|
|
|
|
|
public uiStateLinkClass:string = uiStateLinkClass; |
|
|
|
|
|
|
|
|
|
public selected = false; |
|
|
|
|
|
|
|
|
|
public text = { |
|
|
|
|
removeCard: this.I18n.t('js.card.remove_from_list'), |
|
|
|
|
detailsView: this.I18n.t('js.button_open_details'), |
|
|
|
@ -76,6 +85,7 @@ export class WorkPackageSingleCardComponent extends UntilDestroyedMixin implemen |
|
|
|
|
readonly pathHelper:PathHelperService, |
|
|
|
|
readonly I18n:I18nService, |
|
|
|
|
readonly $state:StateService, |
|
|
|
|
readonly uiRouterGlobals:UIRouterGlobals, |
|
|
|
|
readonly wpTableSelection:WorkPackageViewSelectionService, |
|
|
|
|
readonly wpTableFocus:WorkPackageViewFocusService, |
|
|
|
|
readonly cardView:WorkPackageCardViewService, |
|
|
|
@ -87,11 +97,22 @@ export class WorkPackageSingleCardComponent extends UntilDestroyedMixin implemen |
|
|
|
|
|
|
|
|
|
ngOnInit():void { |
|
|
|
|
// Update selection state
|
|
|
|
|
this.wpTableSelection.live$() |
|
|
|
|
combineLatest([ |
|
|
|
|
this.wpTableSelection.live$(), |
|
|
|
|
this.uiRouterGlobals.params$, |
|
|
|
|
]) |
|
|
|
|
.pipe( |
|
|
|
|
this.untilDestroyed(), |
|
|
|
|
map(() => { |
|
|
|
|
if (this.selectedWhenOpen) { |
|
|
|
|
return this.uiRouterGlobals.params.workPackageId === this.workPackage.id; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return this.wpTableSelection.isSelected(this.workPackage.id as string); |
|
|
|
|
}), |
|
|
|
|
) |
|
|
|
|
.subscribe(() => { |
|
|
|
|
.subscribe((selected) => { |
|
|
|
|
this.selected = selected; |
|
|
|
|
this.cdRef.detectChanges(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -118,7 +139,7 @@ export class WorkPackageSingleCardComponent extends UntilDestroyedMixin implemen |
|
|
|
|
const base = 'op-wp-single-card'; |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
[`${base}_checked`]: this.isSelected(this.workPackage), |
|
|
|
|
[`${base}_selected`]: this.selected, |
|
|
|
|
[`${base}_draggable`]: this.draggable, |
|
|
|
|
[`${base}_new`]: isNewResource(this.workPackage), |
|
|
|
|
[`${base}_shrink`]: this.shrinkOnMobile, |
|
|
|
@ -210,10 +231,6 @@ export class WorkPackageSingleCardComponent extends UntilDestroyedMixin implemen |
|
|
|
|
return wp.bcfViewpoints && wp.bcfViewpoints.length > 0 ? `${wp.bcfViewpoints[0].href}/snapshot` : null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public isSelected(wp:WorkPackageResource):boolean { |
|
|
|
|
return this.wpTableSelection.isSelected(wp.id!); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private cardHighlighting(wp:WorkPackageResource):string { |
|
|
|
|
if (['status', 'priority', 'type'].includes(this.highlightingMode)) { |
|
|
|
|
return Highlighting.backgroundClass(this.highlightingMode, wp[this.highlightingMode].id); |
|
|
|
|