Add path helper to resolve images

pull/8639/head
Oliver Günther 4 years ago
parent d690fdb2bf
commit 02f810c39b
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 18
      frontend/src/app/helpers/images/path-helper.ts
  2. 7
      frontend/src/app/modules/boards/board/board-actions/assignee/assignee-action.service.ts
  3. 3
      frontend/src/app/modules/boards/board/board-actions/status/status-action.service.ts
  4. 4
      frontend/src/app/modules/boards/board/board-actions/subproject/subproject-action.service.ts
  5. 3
      frontend/src/app/modules/boards/board/board-actions/subtasks/board-subtasks-action.service.ts
  6. 3
      frontend/src/app/modules/boards/board/board-actions/version/version-action.service.ts
  7. 27
      frontend/src/app/modules/boards/new-board-modal/new-board-modal.component.ts

@ -0,0 +1,18 @@
export namespace ImageHelpers {
/**
* Returns an absolute asset path from the assets/images/ folder
*
* e.g., to access:
* frontend/src/assets/images/board_creation_modal/assignees.svg
*
* use
* imagePath('board_creation_modal/assignees.svg')
*
*
* @param image Path to the image starting from frontend/src/assets/images
*/
export function imagePath(image:string) {
return __webpack_public_path__ + 'assets/images/' + image;
}
}

@ -6,9 +6,10 @@ import {ProjectResource} from "core-app/modules/hal/resources/project-resource";
import {CachedBoardActionService} from "core-app/modules/boards/board/board-actions/cached-board-action.service";
import {HalResource} from "core-app/modules/hal/resources/hal-resource";
import {Board} from "core-app/modules/boards/board/board";
import {ApiV3Filter, FilterOperator} from "core-components/api/api-v3/api-v3-filter-builder";
import {ApiV3Filter} from "core-components/api/api-v3/api-v3-filter-builder";
import {QueryResource} from "core-app/modules/hal/resources/query-resource";
import {ImageHelpers} from "core-app/helpers/images/path-helper";
import imagePath = ImageHelpers.imagePath;
@Injectable()
export class BoardAssigneeActionService extends CachedBoardActionService {
@ -24,7 +25,7 @@ export class BoardAssigneeActionService extends CachedBoardActionService {
icon = 'icon-user';
image = 'frontend/src/assets/images/board_creation_modal/assignees.svg';
image = ImageHelpers.imagePath('board_creation_modal/assignees.svg');
readonly unassignedUser:any = {
id: null,

@ -4,6 +4,7 @@ import {StatusResource} from "core-app/modules/hal/resources/status-resource";
import {BoardActionService} from "core-app/modules/boards/board/board-actions/board-action.service";
import {CachedBoardActionService} from "core-app/modules/boards/board/board-actions/cached-board-action.service";
import {StatusBoardHeaderComponent} from "core-app/modules/boards/board/board-actions/status/status-board-header.component";
import {ImageHelpers} from "core-app/helpers/images/path-helper";
@Injectable()
export class BoardStatusActionService extends CachedBoardActionService {
@ -19,7 +20,7 @@ export class BoardStatusActionService extends CachedBoardActionService {
icon = 'icon-workflow';
image = 'frontend/src/assets/images/board_creation_modal/status.svg';
image = ImageHelpers.imagePath('board_creation_modal/status.svg');
public get localizedName() {
return this.I18n.t('js.work_packages.properties.status');

@ -4,11 +4,11 @@ import {HalResource} from "core-app/modules/hal/resources/hal-resource";
import {buildApiV3Filter} from "core-components/api/api-v3/api-v3-filter-builder";
import {UserResource} from 'core-app/modules/hal/resources/user-resource';
import {CollectionResource} from 'core-app/modules/hal/resources/collection-resource';
import {input} from "reactivestates";
import {WorkPackageChangeset} from "core-components/wp-edit/work-package-changeset";
import {WorkPackageResource} from "core-app/modules/hal/resources/work-package-resource";
import {SubprojectBoardHeaderComponent} from "core-app/modules/boards/board/board-actions/subproject/subproject-board-header.component";
import {CachedBoardActionService} from "core-app/modules/boards/board/board-actions/cached-board-action.service";
import {ImageHelpers} from "core-app/helpers/images/path-helper";
@Injectable()
export class BoardSubprojectActionService extends CachedBoardActionService {
@ -23,7 +23,7 @@ export class BoardSubprojectActionService extends CachedBoardActionService {
icon = 'icon-projects';
image = 'frontend/src/assets/images/board_creation_modal/subproject.svg';
image = ImageHelpers.imagePath('board_creation_modal/subproject.svg');
get localizedName() {
return this.I18n.t('js.work_packages.properties.subproject');

@ -8,6 +8,7 @@ import {ApiV3FilterBuilder} from "core-components/api/api-v3/api-v3-filter-build
import {SubtasksBoardHeaderComponent} from "core-app/modules/boards/board/board-actions/subtasks/subtasks-board-header.component";
import {QueryResource} from "core-app/modules/hal/resources/query-resource";
import {WorkPackageChangeset} from "core-components/wp-edit/work-package-changeset";
import {ImageHelpers} from "core-app/helpers/images/path-helper";
@Injectable()
export class BoardSubtasksActionService extends BoardActionService {
@ -22,7 +23,7 @@ export class BoardSubtasksActionService extends BoardActionService {
icon = 'icon-hierarchy';
image = 'frontend/src/assets/images/board_creation_modal/parent-child.svg';
image = ImageHelpers.imagePath('board_creation_modal/parent-child.svg');
public get localizedName() {
return this.I18n.t('js.boards.board_type.action_type.subtasks');

@ -13,6 +13,7 @@ import {VersionBoardHeaderComponent} from "core-app/modules/boards/board/board-a
import {FormResource} from "core-app/modules/hal/resources/form-resource";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
import {CachedBoardActionService} from "core-app/modules/boards/board/board-actions/cached-board-action.service";
import {ImageHelpers} from "core-app/helpers/images/path-helper";
@Injectable()
export class BoardVersionActionService extends CachedBoardActionService {
@ -31,7 +32,7 @@ export class BoardVersionActionService extends CachedBoardActionService {
icon = 'icon-getting-started';
image = "frontend/src/assets/images/board_creation_modal/version.svg";
image = ImageHelpers.imagePath('board_creation_modal/version.svg');
private writable$:Promise<boolean>;

@ -37,7 +37,9 @@ import {BoardService} from "core-app/modules/boards/board/board.service";
import {BoardActionsRegistryService} from "core-app/modules/boards/board/board-actions/board-actions-registry.service";
import {LoadingIndicatorService} from "core-app/modules/common/loading-indicator/loading-indicator.service";
import {HalResourceNotificationService} from "core-app/modules/hal/services/hal-resource-notification.service";
import { ITileViewEntry } from '../tile-view/tile-view.component';
import {ITileViewEntry} from '../tile-view/tile-view.component';
import {ImageHelpers} from "core-app/helpers/images/path-helper";
import imagePath = ImageHelpers.imagePath;
@Component({
@ -85,20 +87,26 @@ export class NewBoardModalComponent extends OpModalComponent {
public createBoard(attribute:string) {
if (attribute === 'basic') {
this.createFree();
}
else {
this.createFree();
} else {
this.createAction(attribute);
}
}
private initiateTiles() {
this.available.unshift({attribute:'basic', text:this.text.free_board,
icon:'icon-boards', description:this.text.free_board_text, image: 'frontend/src/assets/images/board_creation_modal/version.png'});
this.available.unshift({
attribute: 'basic',
text: this.text.free_board,
icon: 'icon-boards',
description: this.text.free_board_text,
image: imagePath('board_creation_modal/lists.svg')
});
this.addIcon(this.available);
this.addDescription(this.available);
this.addText(this.available);
this.addImage(this.available);
}
private createFree() {
this.create({ type: 'free' });
}
@ -122,13 +130,16 @@ export class NewBoardModalComponent extends OpModalComponent {
this.halNotification.handleRawError(error);
});
}
private addDescription(tiles:ITileViewEntry[]) {
tiles.forEach(element => {
if (element.attribute !== 'basic') {
const service = this.boardActionRegistry.get(element.attribute!);
element.description = service.description; }
element.description = service.description;
}
});
}
private addIcon(tiles:ITileViewEntry[]) {
tiles.forEach(element => {
if (element.attribute !== 'basic') {
@ -137,6 +148,7 @@ export class NewBoardModalComponent extends OpModalComponent {
}
});
}
private addText(tiles:ITileViewEntry[]) {
tiles.forEach(element => {
if (element.attribute !== 'basic') {
@ -145,6 +157,7 @@ export class NewBoardModalComponent extends OpModalComponent {
}
});
}
private addImage(tiles:ITileViewEntry[]) {
tiles.forEach(element => {
if (element.attribute !== 'basic') {

Loading…
Cancel
Save