Skip to content

Commit

Permalink
Fixed is wip predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
hudson-newey committed Oct 20, 2023
1 parent dee1add commit 5a943ed
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
13 changes: 3 additions & 10 deletions src/app/app.menus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IconProp } from "@fortawesome/fontawesome-svg-core";
import { Inject } from "@angular/core";
import { ConfigService } from "@services/config/config.service";
import { IPageInfo } from "@helpers/page/pageInfo";
import { environment } from "src/environments/environment";
import { Project } from "./models/Project";
import { User } from "./models/User";
import { retrieveResolvedModel } from "./services/baw-api/resolver-common";
Expand Down Expand Up @@ -56,11 +55,5 @@ export const isAdminPredicate = (user: User): boolean =>
*
* @param user User session data. This will be used to check if the user is an admin
*/
export const isWorkInProgressPredicate = (user: User): boolean => {
// const config = Inject(ConfigService);

// const isProduction: boolean = config.environment.production;
const isProduction = false;

return isProduction && isAdminPredicate(user);
};
export const isWorkInProgressPredicate = (user: User): boolean =>
environment.production && isAdminPredicate(user);
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const rootMappingPath = "";
})
export class MetadataReviewComponent
extends withUnsubscribe()
implements OnInit, UnsavedInputCheckingComponent {
implements OnInit, UnsavedInputCheckingComponent
{
/** Changes to harvest have not yet been saved to the server */
public hasUnsavedChanges: boolean;
public newSiteMenuItem = newSiteMenuItem;
Expand Down Expand Up @@ -248,15 +249,14 @@ export class MetadataReviewComponent

public updateHarvestWithMappingChange(): void {
// create a new "temporary" model of the Harvest mappings
const newMappings = new Map(this.harvest.mappings.map(x => [x.path, x]));
const newMappings = new Map(this.harvest.mappings.map((x) => [x.path, x]));

/**
* Iterate through all the rows, extract folders which have mappings and
* push that list to the mappings array. We could use a filter and map for
* this, however it's likely less performant
*/
this.rows.forEach((row): void => {

if (row.rowType === RowType.folder && isInstantiated(row.mapping)) {
const rowMapping = row.mapping;
const existing = newMappings.get(rowMapping.path);
Expand All @@ -266,15 +266,12 @@ export class MetadataReviewComponent
} else {
newMappings.set(rowMapping.path, rowMapping);
}

}

});

const adjustedMappings = Array.from(newMappings.values());

this.hasUnsavedChanges = true;
console.log("here");
this.harvestApi
.updateMappings(this.harvest, adjustedMappings)
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
Expand Down
7 changes: 1 addition & 6 deletions src/app/guards/input/input.guard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Injectable } from "@angular/core";
import { CanDeactivate } from "@angular/router";

export interface UnsavedInputCheckingComponent {
hasUnsavedChanges: boolean;
Expand All @@ -11,12 +10,8 @@ export interface UnsavedInputCheckingComponent {
* modified by the user in any way which has not been saved
*/
@Injectable()
export class UnsavedInputGuard
implements CanDeactivate<UnsavedInputCheckingComponent>
{
export class UnsavedInputGuard {
public canDeactivate(component: UnsavedInputCheckingComponent): boolean {
console.log("sajhdskla");

// canDeactivate guards can be called with null components: https://github.com/angular/angular/issues/40545
if (!component) {
return true;
Expand Down

0 comments on commit 5a943ed

Please sign in to comment.