changed labels for input groups

This commit is contained in:
lotte
2019-09-03 14:15:36 +02:00
parent 5142915e83
commit 4ace067265
11 changed files with 62 additions and 47 deletions

View File

@@ -53,7 +53,7 @@
<div *ngIf="hasRelationLookup" class="mt-3"> <div *ngIf="hasRelationLookup" class="mt-3">
<ul class="list-unstyled"> <ul class="list-unstyled">
<li *ngFor="let result of ( model.value | async); let i = index"> <li *ngFor="let result of ( relationships$ | async); let i = index">
<ng-container *ngVar="result.indexableObject as v"> <ng-container *ngVar="result.indexableObject as v">
<button type="button" class="close float-left" aria-label="Close button" <button type="button" class="close float-left" aria-label="Close button"
(click)="removeSelection(result)"> (click)="removeSelection(result)">

View File

@@ -70,7 +70,7 @@ import { DsDynamicFormArrayComponent } from './models/array-group/dynamic-form-a
import { DsDynamicRelationGroupComponent } from './models/relation-group/dynamic-relation-group.components'; import { DsDynamicRelationGroupComponent } from './models/relation-group/dynamic-relation-group.components';
import { DYNAMIC_FORM_CONTROL_TYPE_RELATION_GROUP } from './models/relation-group/dynamic-relation-group.model'; import { DYNAMIC_FORM_CONTROL_TYPE_RELATION_GROUP } from './models/relation-group/dynamic-relation-group.model';
import { DsDatePickerInlineComponent } from './models/date-picker-inline/dynamic-date-picker-inline.component'; import { DsDatePickerInlineComponent } from './models/date-picker-inline/dynamic-date-picker-inline.component';
import { map, switchMap, take } from 'rxjs/operators'; import { map, switchMap, take, tap } from 'rxjs/operators';
import { SelectableListState } from '../../../object-list/selectable-list/selectable-list.reducer'; import { SelectableListState } from '../../../object-list/selectable-list/selectable-list.reducer';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { SearchResult } from '../../../search/search-result.model'; import { SearchResult } from '../../../search/search-result.model';
@@ -172,7 +172,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
@Input() hasErrorMessaging = false; @Input() hasErrorMessaging = false;
@Input() layout = null as DynamicFormLayout; @Input() layout = null as DynamicFormLayout;
@Input() model: any; @Input() model: any;
relationships$: Observable<SearchResult<Item>[]>;
hasRelationLookup: boolean; hasRelationLookup: boolean;
modalRef: NgbModalRef; modalRef: NgbModalRef;
modelValueMDRepresentation; modelValueMDRepresentation;
@@ -217,10 +217,10 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
map((items: Item[]) => items.map((item) => Object.assign(new SearchResult(), { indexableObject: item }))), map((items: Item[]) => items.map((item) => Object.assign(new SearchResult(), { indexableObject: item }))),
).subscribe((relatedItems) => this.selectableListService.select(this.listId, relatedItems)); ).subscribe((relatedItems) => this.selectableListService.select(this.listId, relatedItems));
this.model.value = this.selectableListService.getSelectableList(this.listId).pipe( this.relationships$ = this.selectableListService.getSelectableList(this.listId).pipe(
map((listState: SelectableListState) => hasValue(listState) && hasValue(listState.selection) ? listState.selection : []), map((listState: SelectableListState) => hasValue(listState) && hasValue(listState.selection) ? listState.selection : []),
); ) as Observable<SearchResult<Item>[]>;
this.modelValueMDRepresentation = this.model.value.pipe(map((result: SearchResult<DSpaceObject>[]) => result.map((element: SearchResult<DSpaceObject>) => Object.assign(new ItemMetadataRepresentation(), element.indexableObject)))) this.modelValueMDRepresentation = this.relationships$.pipe(map((result: SearchResult<DSpaceObject>[]) => result.map((element: SearchResult<DSpaceObject>) => Object.assign(new ItemMetadataRepresentation(), element.indexableObject))));
} }
} }

View File

@@ -15,6 +15,7 @@ export interface DynamicConcatModelConfig extends DynamicFormGroupModelConfig {
workspaceItem: WorkspaceItem; workspaceItem: WorkspaceItem;
relationship?: RelationshipOptions; relationship?: RelationshipOptions;
repeatable: boolean; repeatable: boolean;
required: boolean;
} }
export class DynamicConcatModel extends DynamicFormGroupModel { export class DynamicConcatModel extends DynamicFormGroupModel {
@@ -24,6 +25,7 @@ export class DynamicConcatModel extends DynamicFormGroupModel {
@serializable() workspaceItem: WorkspaceItem; @serializable() workspaceItem: WorkspaceItem;
@serializable() relationship?: RelationshipOptions; @serializable() relationship?: RelationshipOptions;
@serializable() repeatable?: boolean; @serializable() repeatable?: boolean;
@serializable() required?: boolean;
isCustomGroup = true; isCustomGroup = true;
constructor(config: DynamicConcatModelConfig, layout?: DynamicFormControlLayout) { constructor(config: DynamicConcatModelConfig, layout?: DynamicFormControlLayout) {
@@ -34,6 +36,7 @@ export class DynamicConcatModel extends DynamicFormGroupModel {
this.relationship = config.relationship; this.relationship = config.relationship;
this.workspaceItem = config.workspaceItem; this.workspaceItem = config.workspaceItem;
this.repeatable = config.repeatable; this.repeatable = config.repeatable;
this.required = config.required;
} }
get value() { get value() {

View File

@@ -12,6 +12,7 @@ export interface DsDynamicQualdropModelConfig extends DynamicFormGroupModelConfi
languageCodes?: LanguageCode[]; languageCodes?: LanguageCode[];
language?: string; language?: string;
readOnly: boolean; readOnly: boolean;
required: boolean;
} }
export class DynamicQualdropModel extends DynamicFormGroupModel { export class DynamicQualdropModel extends DynamicFormGroupModel {
@@ -20,12 +21,14 @@ export class DynamicQualdropModel extends DynamicFormGroupModel {
@serializable() languageUpdates: Subject<string>; @serializable() languageUpdates: Subject<string>;
@serializable() hasLanguages = false; @serializable() hasLanguages = false;
@serializable() readOnly: boolean; @serializable() readOnly: boolean;
@serializable() required: boolean;
isCustomGroup = true; isCustomGroup = true;
constructor(config: DsDynamicQualdropModelConfig, layout?: DynamicFormControlLayout) { constructor(config: DsDynamicQualdropModelConfig, layout?: DynamicFormControlLayout) {
super(config, layout); super(config, layout);
this.readOnly = config.readOnly; this.readOnly = config.readOnly;
this.required = config.required;
this.language = config.language; this.language = config.language;
this.languageCodes = config.languageCodes; this.languageCodes = config.languageCodes;

View File

@@ -7,15 +7,17 @@ import { DYNAMIC_FORM_CONTROL_TYPE_TAG } from './tag/dynamic-tag.model';
export interface DynamicRowArrayModelConfig extends DynamicFormArrayModelConfig { export interface DynamicRowArrayModelConfig extends DynamicFormArrayModelConfig {
notRepeatable: boolean; notRepeatable: boolean;
required: boolean;
} }
export class DynamicRowArrayModel extends DynamicFormArrayModel { export class DynamicRowArrayModel extends DynamicFormArrayModel {
@serializable() notRepeatable = false; @serializable() notRepeatable = false;
@serializable() required = false;
isRowArray = true; isRowArray = true;
constructor(config: DynamicRowArrayModelConfig, layout?: DynamicFormControlLayout) { constructor(config: DynamicRowArrayModelConfig, layout?: DynamicFormControlLayout) {
super(config, layout); super(config, layout);
this.notRepeatable = config.notRepeatable; this.notRepeatable = config.notRepeatable;
this.required = config.required;
} }
} }

View File

@@ -46,15 +46,16 @@ export class ConcatFieldParser extends FieldParser {
}; };
const groupId = id.replace(/\./g, '_') + CONCAT_GROUP_SUFFIX; const groupId = id.replace(/\./g, '_') + CONCAT_GROUP_SUFFIX;
const concatGroup: DynamicConcatModelConfig = this.initModel(groupId, false, false); const concatGroup: DynamicConcatModelConfig = this.initModel(groupId, label, false);
concatGroup.group = []; concatGroup.group = [];
concatGroup.separator = this.separator; concatGroup.separator = this.separator;
const input1ModelConfig: DynamicInputModelConfig = this.initModel(id + CONCAT_FIRST_INPUT_SUFFIX, label, false, false); const input1ModelConfig: DynamicInputModelConfig = this.initModel(id + CONCAT_FIRST_INPUT_SUFFIX, false, false);
const input2ModelConfig: DynamicInputModelConfig = this.initModel(id + CONCAT_SECOND_INPUT_SUFFIX, label, true, false); const input2ModelConfig: DynamicInputModelConfig = this.initModel(id + CONCAT_SECOND_INPUT_SUFFIX, false, false);
if (this.configData.mandatory) { if (this.configData.mandatory) {
concatGroup.required = true;
input1ModelConfig.required = true; input1ModelConfig.required = true;
} }

View File

@@ -31,12 +31,12 @@ export abstract class FieldParser {
) { ) {
let arrayCounter = 0; let arrayCounter = 0;
let fieldArrayCounter = 0; let fieldArrayCounter = 0;
const config = { const config = {
id: uniqueId() + '_array', id: uniqueId() + '_array',
label: this.configData.label,
initialCount: this.getInitArrayIndex(), initialCount: this.getInitArrayIndex(),
notRepeatable: !this.configData.repeatable, notRepeatable: !this.configData.repeatable,
label: this.configData.label,
required: isNotEmpty(this.configData.mandatory),
groupFactory: () => { groupFactory: () => {
let model; let model;
if ((arrayCounter === 0)) { if ((arrayCounter === 0)) {
@@ -169,7 +169,7 @@ export abstract class FieldParser {
} }
} }
protected initModel(id?: string, label = true, labelEmpty = false, setErrors = true) { protected initModel(id?: string, label = true, setErrors = true) {
const controlModel = Object.create(null); const controlModel = Object.create(null);
@@ -190,7 +190,7 @@ export abstract class FieldParser {
controlModel.repeatable = this.configData.repeatable; controlModel.repeatable = this.configData.repeatable;
// Set label // Set label
this.setLabel(controlModel, label, labelEmpty); this.setLabel(controlModel, label);
controlModel.placeholder = this.configData.label; controlModel.placeholder = this.configData.label;
@@ -243,7 +243,7 @@ export abstract class FieldParser {
protected setLabel(controlModel, label = true, labelEmpty = false) { protected setLabel(controlModel, label = true, labelEmpty = false) {
if (label) { if (label) {
controlModel.label = (labelEmpty) ? '&nbsp;' : this.configData.label; controlModel.label = this.configData.label;
} }
} }

View File

@@ -54,18 +54,20 @@ export class OneboxFieldParser extends FieldParser {
inputSelectGroup.id = newId.replace(/\./g, '_') + QUALDROP_GROUP_SUFFIX; inputSelectGroup.id = newId.replace(/\./g, '_') + QUALDROP_GROUP_SUFFIX;
inputSelectGroup.group = []; inputSelectGroup.group = [];
inputSelectGroup.legend = this.configData.label; inputSelectGroup.legend = this.configData.label;
this.setLabel(inputSelectGroup, label);
inputSelectGroup.required = isNotEmpty(this.configData.mandatory);
const selectModelConfig: DynamicSelectModelConfig<any> = this.initModel(newId + QUALDROP_METADATA_SUFFIX, label); const selectModelConfig: DynamicSelectModelConfig<any> = this.initModel(newId + QUALDROP_METADATA_SUFFIX, false);
this.setOptions(selectModelConfig); this.setOptions(selectModelConfig);
if (isNotEmpty(fieldValue)) { if (isNotEmpty(fieldValue)) {
selectModelConfig.value = fieldValue.metadata; selectModelConfig.value = fieldValue.metadata;
} }
inputSelectGroup.group.push(new DynamicSelectModel(selectModelConfig, clsSelect)); inputSelectGroup.group.push(new DynamicSelectModel(selectModelConfig, clsSelect));
const inputModelConfig: DsDynamicInputModelConfig = this.initModel(newId + QUALDROP_VALUE_SUFFIX, label, true); const inputModelConfig: DsDynamicInputModelConfig = this.initModel(newId + QUALDROP_VALUE_SUFFIX, false);
this.setValues(inputModelConfig, fieldValue); this.setValues(inputModelConfig, fieldValue);
inputSelectGroup.readOnly = selectModelConfig.disabled && inputModelConfig.readOnly; inputSelectGroup.readOnly = selectModelConfig.disabled && inputModelConfig.readOnly;
inputSelectGroup.group.push(new DsDynamicInputModel(inputModelConfig, clsInput)); inputSelectGroup.group.push(new DsDynamicInputModel(inputModelConfig, clsInput));
return new DynamicQualdropModel(inputSelectGroup, clsGroup); return new DynamicQualdropModel(inputSelectGroup, clsGroup);

View File

@@ -12,6 +12,7 @@
(dfFocus)="onFocus($event)"> (dfFocus)="onFocus($event)">
<ng-template modelType="ARRAY" let-group let-index="index" let-context="context"> <ng-template modelType="ARRAY" let-group let-index="index" let-context="context">
<!--Array with repeatable items--> <!--Array with repeatable items-->
<div *ngIf="!context.notRepeatable" <div *ngIf="!context.notRepeatable"
class="col-xs-2 d-flex flex-column justify-content-sm-start align-items-end"> class="col-xs-2 d-flex flex-column justify-content-sm-start align-items-end">

View File

@@ -65,7 +65,8 @@ export const qualdropConfig = {
id: 'dc_identifier_QUALDROP_GROUP', id: 'dc_identifier_QUALDROP_GROUP',
legend: 'Identifiers', legend: 'Identifiers',
readOnly: false, readOnly: false,
group: [mockQualdropSelectModel, mockQualdropInputModel] group: [mockQualdropSelectModel, mockQualdropInputModel],
required: false
}; };
export const MockQualdropModel = new DynamicQualdropModel(qualdropConfig); export const MockQualdropModel = new DynamicQualdropModel(qualdropConfig);

View File

@@ -1,30 +1,32 @@
<ds-pagination <ds-pagination
[paginationOptions]="config" [paginationOptions]="config"
[pageInfoState]="objects?.payload" [pageInfoState]="objects?.payload"
[collectionSize]="objects?.payload?.totalElements" [collectionSize]="objects?.payload?.totalElements"
[sortOptions]="sortConfig" [sortOptions]="sortConfig"
[hideGear]="hideGear" [hideGear]="hideGear"
[hidePagerWhenSinglePage]="hidePagerWhenSinglePage" [hidePagerWhenSinglePage]="hidePagerWhenSinglePage"
(pageChange)="onPageChange($event)" (pageChange)="onPageChange($event)"
(pageSizeChange)="onPageSizeChange($event)" (pageSizeChange)="onPageSizeChange($event)"
(sortDirectionChange)="onSortDirectionChange($event)" (sortDirectionChange)="onSortDirectionChange($event)"
(sortFieldChange)="onSortFieldChange($event)" (sortFieldChange)="onSortFieldChange($event)"
(paginationChange)="onPaginationChange($event)"> (paginationChange)="onPaginationChange($event)">
<ul *ngIf="objects?.hasSucceeded" class="list-unstyled"> <ul *ngIf="objects?.hasSucceeded" class="list-unstyled">
<li *ngFor="let object of objects?.payload?.page; let i = index; let last = last" class="mt-4 mb-4" [class.border-bottom]="hasBorder && !last"> <li *ngFor="let object of objects?.payload?.page; let i = index; let last = last" class="mt-4 mb-4" [class.border-bottom]="hasBorder && !last">
<ng-container *ngVar="selectionService.isObjectSelected(selectionConfig.listId, object) | async as checked"> <span *ngIf="selectable">
<input *ngIf="selectable && selectionConfig.repeatable" class="form-check-input" type="checkbox" <ng-container *ngVar="selectionService?.isObjectSelected(selectionConfig?.listId, object) | async as checked">
[name]="'checkbox' + i" <input *ngIf="selectionConfig.repeatable" class="form-check-input" type="checkbox"
[id]="'object'+i" [name]="'checkbox' + i"
[checked]="checked" [id]="'object'+i"
(change)="selectCheckbox(!checked, object)"> [checked]="checked"
<input *ngIf="selectable && !selectionConfig.repeatable" class="form-check-input" type="radio" (change)="selectCheckbox(!checked, object)">
[name]="'radio' + i" <input *ngIf="!selectionConfig.repeatable" class="form-check-input" type="radio"
[id]="'object'+i" [name]="'radio' + i"
[checked]="checked" [id]="'object'+i"
(click)="selectRadio(!checked, object)"> [checked]="checked"
</ng-container> (click)="selectRadio(!checked, object)">
<ds-wrapper-list-element [object]="object" [index]="i"></ds-wrapper-list-element> </ng-container>
</li> </span>
</ul> <ds-wrapper-list-element [object]="object" [index]="i"></ds-wrapper-list-element>
</li>
</ul>
</ds-pagination> </ds-pagination>