From a7885a0830d8949eea8931515385345efcef773b Mon Sep 17 00:00:00 2001 From: Martin Rojas Miguel Angel Date: Fri, 2 Mar 2018 13:53:31 +0100 Subject: [PATCH] TSK-196 Add accessItems saving feature. --- admin/src/app/app.module.ts | 4 +- ...rization.ts => workbasket-access-items.ts} | 2 +- admin/src/app/services/workbasket.service.ts | 66 +++---- .../src/app/shared/alert/alert.component.scss | 2 +- .../general-message-modal.component.html | 2 +- .../general-message-modal.component.scss | 1 + admin/src/app/shared/utils/utils.ts | 4 + .../access-items/access-items.component.html | 110 +++++++++++ .../access-items.component.scss} | 4 + .../access-items.component.spec.ts} | 16 +- .../access-items/access-items.component.ts | 97 ++++++++++ .../authorizations.component.html | 171 ------------------ .../authorizations.component.ts | 91 ---------- .../details/workbasket-details.component.html | 6 +- .../workbasket-details.component.spec.ts | 4 +- admin/src/assets/_site.scss | 4 - admin/src/index.html | 1 + 17 files changed, 264 insertions(+), 321 deletions(-) rename admin/src/app/model/{workbasket-authorization.ts => workbasket-access-items.ts} (96%) create mode 100644 admin/src/app/workbasket/details/access-items/access-items.component.html rename admin/src/app/workbasket/details/{authorizations/authorizations.component.scss => access-items/access-items.component.scss} (76%) rename admin/src/app/workbasket/details/{authorizations/authorizations.component.spec.ts => access-items/access-items.component.spec.ts} (68%) create mode 100644 admin/src/app/workbasket/details/access-items/access-items.component.ts delete mode 100644 admin/src/app/workbasket/details/authorizations/authorizations.component.html delete mode 100644 admin/src/app/workbasket/details/authorizations/authorizations.component.ts diff --git a/admin/src/app/app.module.ts b/admin/src/app/app.module.ts index fe69bb21d..28541a01f 100644 --- a/admin/src/app/app.module.ts +++ b/admin/src/app/app.module.ts @@ -24,7 +24,7 @@ import { CategoriesadministrationComponent } from './categoriesadministration/ca import { WorkbasketDistributiontargetsComponent } from './workbasket-distributiontargets/workbasket-distributiontargets.component'; import { WorkbasketDetailsComponent } from './workbasket/details/workbasket-details.component'; import { WorkbasketInformationComponent } from './workbasket/details/information/workbasket-information.component'; -import { AuthorizationsComponent } from './workbasket/details/authorizations/authorizations.component'; +import { AccessItemsComponent } from './workbasket/details/access-items/access-items.component'; import { NoAccessComponent } from './workbasket/noAccess/no-access.component'; import { SpinnerComponent } from './shared/spinner/spinner.component'; import { FilterComponent } from './shared/filter/filter.component'; @@ -70,7 +70,7 @@ const DECLARATIONS = [ CategoriestreeComponent, CategoryeditorComponent, CategoriesadministrationComponent, - AuthorizationsComponent, + AccessItemsComponent, WorkbasketDetailsComponent, WorkbasketDistributiontargetsComponent, MasterAndDetailComponent, diff --git a/admin/src/app/model/workbasket-authorization.ts b/admin/src/app/model/workbasket-access-items.ts similarity index 96% rename from admin/src/app/model/workbasket-authorization.ts rename to admin/src/app/model/workbasket-access-items.ts index 1e9f041a8..c7154ddf2 100644 --- a/admin/src/app/model/workbasket-authorization.ts +++ b/admin/src/app/model/workbasket-access-items.ts @@ -1,6 +1,6 @@ import { Links } from "./links"; -export class WorkbasketAuthorization { +export class WorkbasketAccessItems { constructor( public accessItemId: string = '', public workbasketId: string = '', diff --git a/admin/src/app/services/workbasket.service.ts b/admin/src/app/services/workbasket.service.ts index 83152a099..ab3e6285c 100644 --- a/admin/src/app/services/workbasket.service.ts +++ b/admin/src/app/services/workbasket.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { HttpClientModule, HttpClient, HttpHeaders, HttpResponse, HttpErrorResponse } from '@angular/common/http'; import { WorkbasketSummary } from '../model/workbasketSummary'; import { Workbasket } from '../model/workbasket'; -import { WorkbasketAuthorization } from '../model/workbasket-authorization'; +import { WorkbasketAccessItems } from '../model/workbasket-access-items'; import { environment } from '../../environments/environment'; import { Observable } from 'rxjs/Observable'; import { Subject } from 'rxjs/Subject'; @@ -51,38 +51,33 @@ export class WorkbasketService { //#region "REST calls" // GET - getWorkBasketsSummary( forceRequest: boolean = false, - sortBy: string = this.KEY, - order: string = Direction.ASC, - name: string = undefined, - nameLike: string = undefined, - descLike: string = undefined, - owner: string = undefined, - ownerLike: string = undefined, - type: string = undefined, - key: string = undefined, - keyLike: string = undefined, - requiredPermission: string = undefined): Observable { - if(this.workbasketSummaryRef && !forceRequest){ + getWorkBasketsSummary(forceRequest: boolean = false, + sortBy: string = this.KEY, + order: string = Direction.ASC, + name: string = undefined, + nameLike: string = undefined, + descLike: string = undefined, + owner: string = undefined, + ownerLike: string = undefined, + type: string = undefined, + key: string = undefined, + keyLike: string = undefined, + requiredPermission: string = undefined): Observable { + if (this.workbasketSummaryRef && !forceRequest) { return this.workbasketSummaryRef; } return this.httpClient.get(`${environment.taskanaRestUrl}/v1/workbaskets/${this.getWorkbasketSummaryQueryParameters(sortBy, order, name, nameLike, descLike, owner, ownerLike, type, key, keyLike, requiredPermission)}`, this.httpOptions); } - // GET getWorkBasket(url: string): Observable { return this.httpClient.get(url, this.httpOptions); } - - getWorkBasket1(id: string): Observable { - return this.httpClient.get(environment.taskanaRestUrl + '/v1/workbaskets/' + id, this.httpOptions); - } // POST createWorkbasket(url: string, workbasket: Workbasket): Observable { return this.httpClient - .post(url, this.httpOptions); + .post(url, this.httpOptions); } // PUT updateWorkbasket(url: string, workbasket: Workbasket): Observable { @@ -95,22 +90,19 @@ export class WorkbasketService { return this.httpClient.delete(environment.taskanaRestUrl + '/v1/workbaskets/' + id, this.httpOptions); } // GET - getWorkBasketAuthorizations(id: String): Observable { - return this.httpClient.get(environment.taskanaRestUrl + '/v1/workbaskets/' + id + '/authorizations', this.httpOptions); + getWorkBasketAccessItems(id: String): Observable { + return this.httpClient.get(environment.taskanaRestUrl + '/v1/workbaskets/' + id + '/workbasketAccessItems', this.httpOptions); } // POST - createWorkBasketAuthorization(workbasketAuthorization: WorkbasketAuthorization): Observable { - return this.httpClient.post(environment.taskanaRestUrl + '/v1/workbaskets/authorizations', workbasketAuthorization, this.httpOptions); + createWorkBasketAccessItem(workbasketAccessItem: WorkbasketAccessItems): Observable { + return this.httpClient.post(environment.taskanaRestUrl + '/v1/workbaskets/workbasketAccessItems', workbasketAccessItem, this.httpOptions); } // PUT - updateWorkBasketAuthorization(workbasketAuthorization: WorkbasketAuthorization): Observable { - return this.httpClient.put(environment.taskanaRestUrl + '/v1/workbaskets/authorizations/' + workbasketAuthorization.accessId, workbasketAuthorization, this.httpOptions) + updateWorkBasketAccessItem(url: string, workbasketAccessItem: Array): Observable { + return this.httpClient.put(url, + workbasketAccessItem, + this.httpOptions); } - // DELETE - deleteWorkBasketAuthorization(workbasketAuthorization: WorkbasketAuthorization) { - return this.httpClient.delete(environment.taskanaRestUrl + '/v1/workbaskets/authorizations/' + workbasketAuthorization.accessId, this.httpOptions); - } - //#endregion //#region "Service extras" @@ -162,19 +154,19 @@ export class WorkbasketService { return query; } - private handleError (error: Response | any) { + private handleError(error: Response | any) { // In a real world app, you might use a remote logging infrastructure let errMsg: string; if (error instanceof Response) { - const body = error.json() || ''; - const err = JSON.stringify(body); - errMsg = `${error.status} - ${error.statusText || ''} ${err}`; + const body = error.json() || ''; + const err = JSON.stringify(body); + errMsg = `${error.status} - ${error.statusText || ''} ${err}`; } else { - errMsg = error.message ? error.message : error.toString(); + errMsg = error.message ? error.message : error.toString(); } console.error(errMsg); return Observable.throw(errMsg); - } + } //#endregion } diff --git a/admin/src/app/shared/alert/alert.component.scss b/admin/src/app/shared/alert/alert.component.scss index 6b2e98085..a10795195 100644 --- a/admin/src/app/shared/alert/alert.component.scss +++ b/admin/src/app/shared/alert/alert.component.scss @@ -1,6 +1,6 @@ .footer{ - position: fixed; + position: absolute; bottom: 0; width: 100%; margin-bottom: 0px; diff --git a/admin/src/app/shared/general-message-modal/general-message-modal.component.html b/admin/src/app/shared/general-message-modal/general-message-modal.component.html index 3585a4803..56a5d2b8e 100644 --- a/admin/src/app/shared/general-message-modal/general-message-modal.component.html +++ b/admin/src/app/shared/general-message-modal/general-message-modal.component.html @@ -1,6 +1,6 @@