Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Bug archived read only mode variants are editable even tho not persisted #257

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b918ad0
German - translation typo fixed
aiAdrian Aug 20, 2024
2ec2c8a
German - translation typo fixed
aiAdrian Aug 20, 2024
541305d
UI / Dialog - if the variant is not editable -> readonly : disable us…
aiAdrian Aug 20, 2024
628096d
UI / Dialog - if the variant is not editable -> readonly interactive …
aiAdrian Aug 20, 2024
bb004ef
UI / Dialog - if the variant is not editable -> readonly interactive …
aiAdrian Aug 20, 2024
a567f77
UI / Dialog - if the variant is not editable -> readonly interactive …
aiAdrian Aug 20, 2024
d2d23de
UI / Dialog - if the variant is not editable -> readonly interactive …
aiAdrian Aug 20, 2024
c819a53
UI / Dialog - if the variant is not editable -> remove buttons
aiAdrian Aug 20, 2024
1c39ea5
short key removed -> all editing function deleted (e.g. copy is allowed)
aiAdrian Aug 20, 2024
2932365
short key removed -> all editing function deleted (e.g. copy is allowed)
aiAdrian Aug 20, 2024
2b860d2
short key removed -> all editing function deleted (e.g. copy is allowed)
aiAdrian Aug 20, 2024
cb77d88
Merge branch 'main' of https://github.com/SchweizerischeBundesbahnen/…
aiAdrian Aug 26, 2024
f54ecfa
removed unused scss "tags"
aiAdrian Aug 26, 2024
a08c627
Styling and color editor - menu adjusted (polished)
aiAdrian Aug 26, 2024
99f7ccb
fix: missing translations
louisgreiner Aug 26, 2024
d95ad22
typo fixed
aiAdrian Aug 27, 2024
9bdf885
code clean up
aiAdrian Aug 27, 2024
4b6c5e5
if the project is archvied -> variants archive stat can not be edited…
aiAdrian Aug 27, 2024
8c7a5ca
Merge branch 'main' of https://github.com/SchweizerischeBundesbahnen/…
aiAdrian Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ export class NetzgrafikApplicationComponent {
}

getVariantIsWritable(): boolean {
if (this.versionControlService.variant === null) {
return true;
}
return this.versionControlService.variant.isWritable;
return this.versionControlService.getVariantIsWritable();
}

onVariantenClicked() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<div class="node-container" (click)="disapleSectionView($event)">
<div class="node-container" (click)="disableSectionView($event)"
[class.readonly]="!getVariantIsWritable()"
>
<svg
display="block"
width="96px"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
}
}

.readonly {
pointer-events: none;
}

.title_rect {
cursor: pointer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {Trainrun} from "../../models/trainrun.model";
import {PerlenketteConnection} from "../model/perlenketteConnection";
import {PerlenketteItem} from "../model/perlenketteItem";
import {UiInteractionService} from "../../services/ui/ui.interaction.service";
import {VersionControlService} from "../../services/data/version-control.service";

@Component({
selector: "sbb-perlenkette-node",
Expand All @@ -37,6 +38,7 @@ export class PerlenketteNodeComponent implements OnInit {
public trainrunService: TrainrunService,
readonly filterService: FilterService,
readonly uiInteractionService: UiInteractionService,
readonly versionControlService : VersionControlService,
) {
}

Expand All @@ -45,6 +47,10 @@ export class PerlenketteNodeComponent implements OnInit {
this.calculateHeightConnectionSurplus();
}

getVariantIsWritable() : boolean {
return this.versionControlService.getVariantIsWritable();
}

getConnectionIssue(): string {
let amountOfWarningConnections = 0;
this.perlenketteNode.connections.forEach(
Expand Down Expand Up @@ -343,8 +349,10 @@ export class PerlenketteNodeComponent implements OnInit {
);
}

disapleSectionView(event: MouseEvent) {
this.signalIsBeingEdited.next(undefined);
disableSectionView(event: MouseEvent) {
if (!this.getVariantIsWritable()) {
this.signalIsBeingEdited.next(undefined);
}
event.stopPropagation();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div
[class.sectionEditingContainer]="isBeingEdited() === 'TimeEditor'"
(click)="disableSectionView($event)"
[class.readonly]="!getVariantIsWritable()"
>
<!--- START - RENDER SVG --->
<svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ svg {
overflow: visible;
}


.readonly {
pointer-events: none;
}


.start_text {
text-anchor: start !important;
cursor: pointer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
} from "../../view/rastering/definitions";
import {StaticDomTags} from "../../view/editor-main-view/data-views/static.dom.tags";
import {MathUtils} from "../../utils/math";
import {VersionControlService} from "../../services/data/version-control.service";

export interface TopAndBottomTimeStructure {
leftDepartureTime: number;
Expand Down Expand Up @@ -105,6 +106,7 @@ export class PerlenketteSectionComponent
public trainrunSectionTimesService: TrainrunSectionTimesService,
readonly filterService: FilterService,
private loadPerlenketteService: LoadPerlenketteService,
private versionControlService : VersionControlService
) {
this.trainrunSectionHelper = new TrainrunsectionHelper(
this.trainrunService,
Expand Down Expand Up @@ -170,6 +172,10 @@ export class PerlenketteSectionComponent
this.destroyed$.complete();
}

getVariantIsWritable() : boolean {
return this.versionControlService.getVariantIsWritable();
}

isBeingEdited(): string {
if (this.perlenketteSection.isBeingEdited === false) {
return "Rendering";
Expand Down Expand Up @@ -216,7 +222,9 @@ export class PerlenketteSectionComponent
}

disableSectionView(event: MouseEvent) {
this.signalIsBeingEdited.next(this.perlenketteSection);
if (!this.getVariantIsWritable()) {
this.signalIsBeingEdited.next(this.perlenketteSection);
}
event.stopPropagation();
}

Expand Down
10 changes: 9 additions & 1 deletion src/app/perlenkette/perlenkette.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {EditorMode} from "../view/editor-menu/editor-mode";
import {NodeService} from "../services/data/node.service";
import {takeUntil} from "rxjs/operators";
import {PerlenketteConnection} from "./model/perlenketteConnection";
import {VersionControlService} from "../services/data/version-control.service";

@Component({
selector: "sbb-perlenkette",
Expand Down Expand Up @@ -53,6 +54,7 @@ export class PerlenketteComponent implements AfterContentChecked, OnDestroy {
readonly filterService: FilterService,
private readonly uiInteractionService: UiInteractionService,
private readonly nodeService: NodeService,
private versionControlService : VersionControlService,
private changeDetectorRef: ChangeDetectorRef,
) {
this.selectedPerlenketteConnection = undefined;
Expand Down Expand Up @@ -227,8 +229,14 @@ export class PerlenketteComponent implements AfterContentChecked, OnDestroy {
return this.signalAllChildrenIsBeingEditedSubject.asObservable();
}

getVariantIsWritable() : boolean {
return this.versionControlService.getVariantIsWritable();
}

disableSectionView() {
this.signalIsBeingEdited(undefined);
if (!this.getVariantIsWritable()) {
this.signalIsBeingEdited(undefined);
}
}

scrollFirst(event: MouseEvent) {
Expand Down
7 changes: 7 additions & 0 deletions src/app/services/data/version-control.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ export class VersionControlService implements OnDestroy {
this.load(this.variant.id, loadModel);
}

getVariantIsWritable(): boolean {
if (this.variant === null) {
return true;
}
return this.variant.isWritable;
}

createSnapshot(newName?: string): void {
const name = newName || this.variant.latestVersion.name;
this.versionsBackendService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div sbbDialogContent class="EditTrainrunFilterableLabelsDialogTabContent">
<div sbbDialogContent [class]="getContentClassTag()">
<sbb-form-field class="sbb-form-field-long" [label]="'app.view.dialogs.trainrun-and-section-dialog.trainrun-filter-tab.labels' | translate">
<sbb-chip-list
[value]="trainrunLabels"
Expand Down Expand Up @@ -30,7 +30,7 @@
</sbb-autocomplete>
</sbb-form-field>
</div>
<div sbbDialogActions class="EditTrainrunDialogTabFooter">
<div sbbDialogActions [class]="getContentFooterClassTag()">
<button
class="FunctionButton"
tabindex="-1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@
max-height: 48px;
min-height: 48px;
}

::ng-deep div.EditTrainrunFilterableLabelsDialogTabContent.readonly {
pointer-events: none;
}

::ng-deep div.EditTrainrunDialogTabFooter.readonly {
pointer-events: none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {Subject} from "rxjs";
import {takeUntil} from "rxjs/operators";
import {SbbChipEvent, SbbChipInputEvent} from "@sbb-esta/angular/chips";
import {COMMA, ENTER} from "@angular/cdk/keycodes";
import {VersionControlService} from "../../../../services/data/version-control.service";

@Component({
selector: "sbb-trainrun-filter-tab",
Expand All @@ -43,6 +44,7 @@ export class TrainrunFilterTabComponent implements OnInit, OnDestroy {
private labelService: LabelService,
private labelGroupService: LabelGroupService,
private uiInteractionService: UiInteractionService,
private versionControlService: VersionControlService,
private cd: ChangeDetectorRef,
) {
this.initializeWithCurrentSelectedTrainrun();
Expand All @@ -69,6 +71,23 @@ export class TrainrunFilterTabComponent implements OnInit, OnDestroy {
this.destroyed.complete();
}

getContentClassTag() : string {
const retVal = "EditTrainrunFilterableLabelsDialogTabContent";
if (this.versionControlService.getVariantIsWritable()){
return retVal;
}
return retVal + " readonly";
}

getContentFooterClassTag(): string {
const retVal: string = "EditTrainrunDialogTabFooter";
if (this.versionControlService.getVariantIsWritable()) {
return retVal;
}
return retVal + " readonly";
}


remove(chipEvent: SbbChipEvent): void {
const valueDelete = chipEvent.chip.value as string;
const value = (valueDelete || "").trim();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div sbbDialogContent [class]="getDialogContentClassTag()">
<div sbbDialogContent [class]="getContentClassTag()">
<sbb-form-field [label]="'app.view.dialogs.trainrun-and-section-dialog.trainrun-tab.tabName' | translate" class="sbb-form-field-long">
<input
id="trainrunTitleField"
Expand Down Expand Up @@ -59,7 +59,7 @@
</div>
</div>
<ng-container *ngIf="toolbarVisible">
<div sbbDialogActions class="EditTrainrunDialogTabFooter">
<div sbbDialogActions [class]="getContentFooterClassTag()">
<button
class="FunctionButton"
tabindex="-1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,11 @@
}


::ng-deep div.EditTrainrunDialogTabContent.readonly {
pointer-events: none;
}

::ng-deep div.EditTrainrunDialogTabFooter.readonly {
pointer-events: none;
opacity: 0.5;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {StaticDomTags} from "../../../editor-main-view/data-views/static.dom.tag
import {takeUntil} from "rxjs/operators";
import {Subject} from "rxjs";
import {TrainrunDialogParameter} from "../trainrun-and-section-dialog.component";
import {VersionControlService} from "../../../../services/data/version-control.service";

@Component({
selector: "sbb-trainrun-tab",
Expand All @@ -39,6 +40,7 @@ export class TrainrunTabComponent implements OnDestroy {
private trainrunService: TrainrunService,
private trainrunSectionService: TrainrunSectionService,
private uiInteractionService: UiInteractionService,
private versionControlService: VersionControlService,
) {
this.initializeWithCurrentSelectedTrainrun();
this.trainrunService.trainruns
Expand All @@ -53,13 +55,23 @@ export class TrainrunTabComponent implements OnDestroy {
this.destroyed.complete();
}

getDialogContentClassTag(): string {
getContentClassTag(): string {
const readonlyTag: string = this.versionControlService.getVariantIsWritable() ? " " : " readonly";
if (this.isIntegratedComponent) {
return "EditTrainrunDialogTabContent IntegratedComponent";
return "EditTrainrunDialogTabContent IntegratedComponent" + readonlyTag;
}
return "EditTrainrunDialogTabContent";
return "EditTrainrunDialogTabContent" + readonlyTag;
}

getContentFooterClassTag(): string {
const retVal: string = "EditTrainrunDialogTabFooter";
if (this.versionControlService.getVariantIsWritable()) {
return retVal;
}
return retVal + " readonly";
}


getFrequencyClassname(trainrunFrequency: TrainrunFrequency): string {
if (trainrunFrequency.id === this.selectedFrequency.id) {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div sbbDialogContent class="EditTrainrunSectionDialogTabContent">
<div sbbDialogContent [class]="getContentClassTag()">
<table>
<tr>
<td>
Expand Down Expand Up @@ -467,7 +467,7 @@
</tr>
</table>
</div>
<div sbbDialogActions class="EditTrainrunDialogTabFooter">
<div sbbDialogActions [class]="getContentFooterClassTag()">
<button
class="warning"
*ngIf="trainrunSectionTimesService.getShowWarningTwoLocks() === true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,13 @@ div.sbb-dialog-content.sbb-scrollbar.EditTrainrunSectionDialogTabContent {
max-height: 48px;
min-height: 48px;
}


::ng-deep div.EditTrainrunSectionDialogTabContent.readonly {
pointer-events: none;
}

::ng-deep div.EditTrainrunDialogTabFooter.readonly {
pointer-events: none;
opacity: 0.5;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {ColorRefType} from "../../../../data-structures/technical.data.structure
import {
TrainrunSectionTimesService
} from "../../../../services/data/trainrun-section-times.service";
import {VersionControlService} from "../../../../services/data/version-control.service";

export interface LeftAndRightTimeStructure {
leftDepartureTime: number;
Expand Down Expand Up @@ -83,6 +84,7 @@ export class TrainrunSectionTabComponent implements AfterViewInit, OnDestroy {
private trainrunSectionService: TrainrunSectionService,
private changeDetection: ChangeDetectorRef,
public trainrunSectionTimesService: TrainrunSectionTimesService,
private versionControlService: VersionControlService,
) {

this.trainrunSectionHelper = new TrainrunsectionHelper(
Expand Down Expand Up @@ -180,6 +182,22 @@ export class TrainrunSectionTabComponent implements AfterViewInit, OnDestroy {
this.changeDetection.detectChanges();
}

getContentClassTag() : string {
const retVal: string = "EditTrainrunSectionDialogTabContent";
if (this.versionControlService.getVariantIsWritable()){
return retVal;
}
return retVal + " readonly";
}

getContentFooterClassTag() : string {
const retVal: string = "EditTrainrunDialogTabFooter";
if (this.versionControlService.getVariantIsWritable()){
return retVal;
}
return retVal + " readonly";
}

setFocusToUIElement(focusElement: LeftAndRightElement) {
switch (focusElement) {
case LeftAndRightElement.LeftArrival:
Expand Down
Loading