Skip to content

Commit

Permalink
https://github.com/DASISH/qddt-client/issues/771
Browse files Browse the repository at this point in the history
  • Loading branch information
StigNorland committed Feb 8, 2022
1 parent f334a22 commit 56a5d8b
Show file tree
Hide file tree
Showing 20 changed files with 119 additions and 108 deletions.
2 changes: 1 addition & 1 deletion src/app/components/revision/revision.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class RevisionComponent implements OnChanges {

private getChildrenSize(): number {
if (this.isResponseDomain(this.current)) {
return this.current._embedded?.managedRepresentation.children.length;
return this.current.managedRepresentation.children.length;
}
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/table/table.column.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const SEQUENCE_CONSTRUCT_COLUMNS = [
];

const CONDITION_CONSTRUCT_COLUMNS = [
new Column({ label: 'Label', name: 'label', sortable: true }),
new Column({ label: 'Name', name: 'name', sortable: true }),
new Column({ label: 'Condition', name: 'condition', sortable: true })
];
Expand All @@ -47,7 +48,7 @@ const PUBLICATION_COLUMNS = [
const CATEGORY_COLUMNS = [
new Column({ name: 'label', label: 'Label', sortable: true }),
new Column({ name: 'name', label: 'Name', sortable: true }),
new Column({ name: 'description', label: 'Description', sortable: true }),
// new Column({ name: 'description', label: 'Description', sortable: true }),
new Column({ name: 'xmlLang', label: 'Language', sortable: true })
];

Expand Down
1 change: 0 additions & 1 deletion src/app/components/table/table.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { Subject } from 'rxjs';
// import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, Inject, LOCALE_ID } from '@angular/core';
import { Component,OnInit, OnChanges, OnDestroy, Input, Output, EventEmitter, Inject, LOCALE_ID, SimpleChanges } from '@angular/core';
import { formatDate } from '@angular/common';
import { Column } from './table.column';
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/template/template-detail.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div *ngIf="item">
<!-- <div *ngIf="item"> -->

<div class="fixed-action-btn vertical click-to-toggle direction-top">
<a class="btn-floating btn-large cyan"><i class="large material-icons">menu</i></a>
Expand Down Expand Up @@ -48,7 +48,7 @@

<qddt-revision class="row" *ngIf="revisionIsVisible" [current]="item"> </qddt-revision>

<qddt-comment-list [ownerId]="item.id" [comments]="item.comments">
<qddt-comment-list [ownerId]="item?.id" [comments]="item?.comments">
</qddt-comment-list>
</div>
</div>
<!-- </div> -->
2 changes: 1 addition & 1 deletion src/app/components/template/template-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class TemplateListComponent implements OnInit, OnDestroy {
this.pageSearch.page = new Page(result.page);
let resourceName = getQueryInfo(this.pageSearch.kind).halName;
if (result._embedded) {
this.items = result._embedded[resourceName] as HalResource[];
this.items = result._embedded[resourceName] as HalResource[] ||[];
}else{
this.items = []
}
Expand Down
38 changes: 21 additions & 17 deletions src/app/lib/classes/category.classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class Category implements IEntityEditAudit {
basedOn?: IRevId;

changeComment?: string;
modified: number =0;
modified?: number;
modifiedBy?: User|string;
version?: IVersion;
agency?: Agency;
Expand All @@ -82,15 +82,6 @@ export class Category implements IEntityEditAudit {
xmlLang: string; // = 'en-GB';
comments?: IComment[];
children?: Category[]
// get children(): Category[] {
// if (!this._embedded.children)
// this._embedded.children = []
// return this._embedded.children;
// }
// set children(value: Category[]) {
// this._embedded.children = value;
// }

_embedded?: {
[rel: string]: any;
} = {}
Expand All @@ -101,12 +92,28 @@ export class Category implements IEntityEditAudit {
} else if (this.label && !this.name) {
this.name = this.label.toLocaleUpperCase();
}
this.code = (init) ? new Code(init.code) : new Code();
if (!this._embedded)
this.code = ((init) && (init.code)) ? new Code(init.code) : null
if (!this._embedded) {
this._embedded = {}
}
console.group(this.name)
console.debug(this.anchors)
console.groupEnd()
this.anchors?.forEach(value => new Category(value));
}

this.children = ((init) && (init.children)) ? init.children.map(value => new Category(value)) : [];
get anchors() : Category[]{
return this.children || this._embedded.children as Category[] || []
}
set anchors(category:Category[]) {
if (this.children){
this.children = category
} else {
this._embedded.children = category
}
}



public setKind(kind: CategoryKind): Category {
this.hierarchyLevel = HierarchyLevel[CATEGORY_INFO[kind].level];
Expand All @@ -120,8 +127,5 @@ export class Category implements IEntityEditAudit {
return this;
}

public setChildren(children: Category[]): Category {
this._embedded.children = children
return this
}

}
2 changes: 1 addition & 1 deletion src/app/lib/classes/questionitem.classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class QuestionItem implements IEntityEditAudit {
agency: Agency;
name = '';
modified: number;
version: IVersion = { major: 0, minor: 0 };
version: IVersion = { major: 1, minor: 0 };
classKind = ElementKind[ElementKind.QUESTION_ITEM];
basedOn?: IRevId;
changeComment?: string;
Expand Down
41 changes: 22 additions & 19 deletions src/app/lib/classes/responsedomain.classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class ResponseDomain implements IEntityEditAudit {
basedOn?: IRevId;

modified?: number;
version?: IVersion = { major: 0, minor: 0 };
version?: IVersion = { major: 1, minor: 0 };
xmlLang?: string;
_links?: {
[rel: string]: HalLink;
Expand All @@ -77,31 +77,34 @@ export class ResponseDomain implements IEntityEditAudit {
[rel: string]: any;
};

get managedRep(): Category {
return this.managedRepresentation || this._embedded.managedRepresentation
}
set managedRep(category:Category) {
if (this.managedRepresentation){
this.managedRepresentation = category
} else {
this._embedded.managedRepresentation = category
public constructor(init?: Partial<ResponseDomain>) {
if (init?._embedded?.managedRepresentation) {
init.managedRepresentation = init?._embedded?.managedRepresentation
init._embedded.managedRepresentation = null
}
}

public constructor(init?: Partial<ResponseDomain>) {
Object.assign(this, init);
if (init && init.xmlLang) {
if (!this._embedded)
if (!this._embedded) {
this._embedded = {};
}
if(!this.managedRepresentation) {
console.debug("ingen managedRepresentation?")
this.managedRepresentation = new Category({xmlLang: init.xmlLang, name: init.name})
} else {
console.debug("init managedRepresentation")
this.managedRepresentation = new Category(this.managedRepresentation)
this.managedRepresentation.name = this.name
}
}
}


public get isMixed() { return (this.responseKind === 'MIXED'); }

public get getChildren() { return this.managedRepresentation._embedded?.children || this.managedRepresentation.children; }

public get missing(): Category {
return this.getChildren.find(e => e.categoryKind === 'MISSING_GROUP');
return this.managedRepresentation.anchors.find(e => e.categoryKind === 'MISSING_GROUP');
}

public setResponseKind(kind: DomainKind): ResponseDomain {
Expand All @@ -121,17 +124,17 @@ public get missing(): Category {
this.managedRepresentation = new Category({
name: 'Mixed [ renamed in service ]',
xmlLang: this.xmlLang,
}).setChildren([this.managedRepresentation]);
children:[this.managedRepresentation]
})
this.id = null;
this.setResponseKind(DomainKind.MIXED);
}
const filtered = this.getChildren.filter(e => e.categoryKind !== rep.categoryKind);
const filtered = this.managedRepresentation.anchors.filter(e => e.categoryKind !== rep.categoryKind);
filtered.push(rep);
// there is no other children or this is a mixed responseDomain....
this.managedRepresentation.children = filtered;
this.managedRepresentation.anchors = filtered;
this.name = this.managedRepresentation.label =
'Mixed (' + this.managedRepresentation.children.map(c => c.label).join(' + ') + ')';
'Mixed (' + this.managedRepresentation.anchors.map(c => c.label).join(' + ') + ')';
}

}

4 changes: 2 additions & 2 deletions src/app/lib/consts/query-info.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const QDDT_QUERY_INFOS: QueryInfo[] = [
ElementKind.CONDITION_CONSTRUCT,
'Condition',
'controlconstruct',
'controlConstructs',
'conditionConstructs',
['label', 'name', 'description'],
'&constructKind=CONDITION_CONSTRUCT'
),
Expand All @@ -65,7 +65,7 @@ export const QDDT_QUERY_INFOS: QueryInfo[] = [
ElementKind.STATEMENT_CONSTRUCT,
'Statement',
'controlconstruct',
'controlConstructs',
'statementItems',
['label', 'name', 'description'],
'&constructKind=STATEMENT_CONSTRUCT'
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ng-template #conceptTemplateRef let-concepts="children" let-level="level">
<ul *ngIf="concepts">
<li *ngFor="let concept of concepts; trackBy:trackByIndex;" class="scrollspy" [id]="concept.id">
<div class="card section row grey-text text-darken-2" [ngClass]="{'editGreen': edit.isVisible}">
<div class="card section row grey-text text-darken-2" [ngClass]="{'editGreen': edit.isVisible}" style="margin-left: -0.6rem;" >
<div class="col s1">
<ul class="dropdownmenu">
<li *ngIf="canUpdate && !(concept.isArchived)">
Expand Down
4 changes: 4 additions & 0 deletions src/app/modules/home/concept/concept.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import {
selector: 'qddt-concept',
providers: [{ provide: 'elementKind', useValue: 'CONCEPT' },],
templateUrl: './concept.component.html',
styles: [
'.card.section.row { margin-left: -0.6rem; }',
'.dropdownmenu { top:1rem; position:relative;}'
],
animations: [fadeInAnimation],
host: { '[@fadeInAnimation]': '' }
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ResponsedomainCodeListComponent implements OnChanges {
this.rows = [];
const rep = this.managedRepresentation;

for (const c of rep.children) {
for (const c of rep.anchors) {
const newLocal = { label: c.label, value: c.code.value, checked: false } as UserResponse;
this.rows.push(newLocal);
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/modules/preview/responsedomain/missing.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { hasChanges } from 'src/app/lib/consts';
@Component({
selector: 'qddt-preview-rd-missing',
template: `
<ng-container *ngIf="missing?.children">
<ng-container *ngIf="missing?.anchors">
<span style="font-weight: bold;">
<label>Missing</label>
</span>
<div *ngFor="let category of missing.children;" >
<div *ngFor="let category of missing.anchors;" >
<span class="codeValue"> {{ category.code?.value }} </span>
<label>
<input [name]="inputGroupName" type="radio" (change)="checkOption(category)" [checked]="unchecked"/>
Expand Down Expand Up @@ -43,7 +43,7 @@ export class ResponsedomainMissingComponent implements OnChanges {
if (this.managedRepresentation.categoryKind === 'MISSING_GROUP') {
return this.managedRepresentation;
}
return this.managedRepresentation.children.find(e => e.categoryKind === 'MISSING_GROUP');
return this.managedRepresentation.anchors.find(e => e.categoryKind === 'MISSING_GROUP');
}

public checkOption(category: Category) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/preview/responsedomain/mixed.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { Category, ResponseCardinality, UserResponse, Parameter } from '../../..
selector: 'qddt-preview-rd-mixed',
template: `
<ng-container>
<label *ngIf="managedRepresentation && managedRepresentation.children.length > 0" class="active teal-text" title="Response Cardinality: from {{responseCardinality.minimum}} to {{responseCardinality.maximum}}">
<label *ngIf="managedRepresentation && managedRepresentation.anchors.length > 0" class="active teal-text" title="Response Cardinality: from {{responseCardinality.minimum}} to {{responseCardinality.maximum}}">
{{ managedRepresentation.label }} v.<qddt-version [element]="managedRepresentation" ></qddt-version>
</label>
<ng-container *ngFor="let rep of managedRepresentation.children; let idx = index;">
<ng-container *ngFor="let rep of managedRepresentation.anchors; let idx = index;">
<ng-container [ngSwitch]="rep.categoryKind">
<qddt-preview-rd-scale *ngSwitchCase="'SCALE'"
[managedRepresentation]="rep"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class PreviewResponsedomainComponent implements OnChanges {
if (hasChanges(changes.responseDomain)) {
this.responseDomain = new ResponseDomain(changes.responseDomain.currentValue)
this.responseKind = DomainKind[this.responseDomain.responseKind];
this.rep = this.responseDomain.managedRep
this.rep = this.responseDomain.managedRepresentation
this.cardinality = new ResponseCardinality(this.responseDomain.responseCardinality);
this.displayLayout = +this.responseDomain.displayLayout;
}
Expand Down
2 changes: 0 additions & 2 deletions src/app/modules/preview/responsedomain/scale.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
<table>
<thead>
<tr>
<!-- <tr> style="white-space: pre-line;"> -->
<th *ngFor="let item of headers">
<!-- style="padding: 0; transform: rotate(-45deg);"> -->
<label>{{ insertParam(item.label) }}</label>
</th>
</tr>
Expand Down
6 changes: 3 additions & 3 deletions src/app/modules/preview/responsedomain/scale.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class ResponsedomainScaleComponent implements OnChanges, AfterViewInit {

if (!rep) { return; }

const categories = rep.children.map(x => Object.assign({}, x))
const categories = rep.anchors.map(x => Object.assign({}, x))
.sort((a, b) => +a.code.value - +b.code.value);

for (let i = this.min; i <= this.max; i += this.stepUnit) {
Expand All @@ -113,8 +113,8 @@ export class ResponsedomainScaleComponent implements OnChanges, AfterViewInit {
this.headers = [];
let categories: any[] = [];
const rep = this.managedRepresentation;
if (rep !== undefined && rep.children !== undefined) {
categories = rep.children;
if (rep !== undefined && rep.anchors !== undefined) {
categories = rep.anchors;
}
for (let i = this.min; i <= this.max; i++) {
const c = categories
Expand Down
Loading

0 comments on commit 56a5d8b

Please sign in to comment.