diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index 3ae9fd5407..e57f1b45c6 100644 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -8,6 +8,7 @@ import { CommonModule } from '@angular/common'; import { StoreModule } from '@ngrx/store'; import { EffectsModule } from '@ngrx/effects'; +import { DynamicFormLayoutService, DynamicFormService, DynamicFormValidationService } from '@ng-dynamic-forms/core'; import { coreEffects } from './core.effects'; import { coreReducers } from './core.reducers'; @@ -21,6 +22,8 @@ import { DebugResponseParsingService } from './data/debug-response-parsing.servi import { DSOResponseParsingService } from './data/dso-response-parsing.service'; import { SearchResponseParsingService } from './data/search-response-parsing.service'; import { DSpaceRESTv2Service } from './dspace-rest-v2/dspace-rest-v2.service'; +import { FormBuilderService } from '../shared/form/builder/form-builder.service'; +import { FormService } from '../shared/form/form.service'; import { HostWindowService } from '../shared/host-window.service'; import { ItemDataService } from './data/item-data.service'; import { MetadataService } from './metadata/metadata.service'; @@ -39,6 +42,8 @@ import { RouteService } from '../shared/route.service'; import { SubmissionDefinitionsConfigService } from './config/submission-definitions-config.service'; import { SubmissionFormsConfigService } from './config/submission-forms-config.service'; import { SubmissionSectionsConfigService } from './config/submission-sections-config.service'; +import { AuthorityService } from './integration/authority.service'; +import { IntegrationResponseParsingService } from './integration/integration-response-parsing.service'; import { UUIDService } from './shared/uuid.service'; import { HALEndpointService } from './shared/hal-endpoint.service'; import { FacetValueResponseParsingService } from './data/facet-value-response-parsing.service'; @@ -66,6 +71,11 @@ const PROVIDERS = [ CollectionDataService, DSOResponseParsingService, DSpaceRESTv2Service, + DynamicFormLayoutService, + DynamicFormService, + DynamicFormValidationService, + FormBuilderService, + FormService, HALEndpointService, HostWindowService, ItemDataService, @@ -89,6 +99,8 @@ const PROVIDERS = [ SubmissionDefinitionsConfigService, SubmissionFormsConfigService, SubmissionSectionsConfigService, + AuthorityService, + IntegrationResponseParsingService, UploaderService, UUIDService, { provide: NativeWindowService, useFactory: NativeWindowFactory } diff --git a/src/app/core/data/config-response-parsing.service.ts b/src/app/core/data/config-response-parsing.service.ts index 033c9ddc68..dfbbfc50c7 100644 --- a/src/app/core/data/config-response-parsing.service.ts +++ b/src/app/core/data/config-response-parsing.service.ts @@ -27,7 +27,7 @@ export class ConfigResponseParsingService extends BaseResponseParsingService imp } parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse { - if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links) && data.statusCode === '200') { + if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links) && (data.statusCode === '201' || data.statusCode === '200' || data.statusCode === 'OK')) { const configDefinition = this.process(data.payload, request.href); return new ConfigSuccessResponse(configDefinition[Object.keys(configDefinition)[0]], data.statusCode, this.processPageInfo(data.payload)); } else { diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control.component.html index de30440dc2..f26238cc1f 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control.component.html @@ -93,8 +93,10 @@ [ngClass]="getClass('element', 'control', checkboxModel)">
-
+
+ +
-
+
+ +
-
- + diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control.component.ts index dc60697c1f..cd6557b560 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control.component.ts @@ -34,8 +34,8 @@ import { import { DYNAMIC_FORM_CONTROL_TYPE_TYPEAHEAD } from './models/typeahead/dynamic-typeahead.model'; import { DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN } from './models/scrollable-dropdown/dynamic-scrollable-dropdown.model'; import { DYNAMIC_FORM_CONTROL_TYPE_TAG } from './models/tag/dynamic-tag.model'; -import { DYNAMIC_FORM_CONTROL_TYPE_RELATION } from './models/ds-dynamic-group/dynamic-group.model'; -import { DYNAMIC_FORM_CONTROL_TYPE_DSDATEPICKER } from './models/ds-date-picker/ds-date-picker.model'; +import { DYNAMIC_FORM_CONTROL_TYPE_RELATION } from './models/dynamic-group/dynamic-group.model'; +import { DYNAMIC_FORM_CONTROL_TYPE_DSDATEPICKER } from './models/date-picker/date-picker.model'; import { DYNAMIC_FORM_CONTROL_TYPE_LOOKUP } from './models/lookup/dynamic-lookup.model'; import { DynamicListCheckboxGroupModel } from './models/list/dynamic-list-checkbox-group.model'; import { DynamicListRadioGroupModel } from './models/list/dynamic-list-radio-group.model'; diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-date-picker/ds-date-picker.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.html similarity index 100% rename from src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-date-picker/ds-date-picker.component.html rename to src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.html diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-date-picker/ds-date-picker.component.scss b/src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.scss similarity index 100% rename from src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-date-picker/ds-date-picker.component.scss rename to src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.scss diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-date-picker/ds-date-picker.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.ts similarity index 96% rename from src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-date-picker/ds-date-picker.component.ts rename to src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.ts index 6b661c65c9..663e17c0b1 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-date-picker/ds-date-picker.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.ts @@ -1,13 +1,13 @@ import { Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core'; import { FormGroup } from '@angular/forms'; -import { DynamicDsDatePickerModel } from './ds-date-picker.model'; +import { DynamicDsDatePickerModel } from './date-picker.model'; export const DS_DATE_PICKER_SEPARATOR = '-'; @Component({ selector: 'ds-date-picker', - styleUrls: ['./ds-date-picker.component.scss'], - templateUrl: './ds-date-picker.component.html', + styleUrls: ['./date-picker.component.scss'], + templateUrl: './date-picker.component.html', }) export class DsDatePickerComponent implements OnInit { diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-date-picker/ds-date-picker.model.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.model.ts similarity index 100% rename from src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-date-picker/ds-date-picker.model.ts rename to src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.model.ts diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.component.html similarity index 100% rename from src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.component.html rename to src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.component.html diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.component.scss b/src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.component.scss similarity index 100% rename from src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.component.scss rename to src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.component.scss diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.components.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.components.ts similarity index 99% rename from src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.components.ts rename to src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.components.ts index f74de35110..7c209966c2 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.components.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.components.ts @@ -63,7 +63,6 @@ export class DsDynamicGroupComponent implements OnDestroy, OnInit { } ngOnInit() { - console.log(this.model.hasErrorMessages); const config = {rows: this.model.formConfiguration} as SubmissionFormsModel; if (isNotEmpty(this.model.value)) { this.formCollapsed = Observable.of(true); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.model.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.model.ts similarity index 100% rename from src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.model.ts rename to src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.model.ts diff --git a/src/app/shared/form/builder/form-builder.service.ts b/src/app/shared/form/builder/form-builder.service.ts index 8e61f80af4..78509f76de 100644 --- a/src/app/shared/form/builder/form-builder.service.ts +++ b/src/app/shared/form/builder/form-builder.service.ts @@ -12,12 +12,12 @@ import { } from '@ng-dynamic-forms/core'; import { mergeWith } from 'lodash'; -import { isEmpty, isNotEmpty, isNotNull, isNull } from '../../empty.util'; +import { isEmpty, isNotEmpty, isNotNull, isNotUndefined, isNull } from '../../empty.util'; import { DynamicComboboxModel } from './ds-dynamic-form-ui/models/ds-dynamic-combobox.model'; import { SubmissionFormsModel } from '../../../core/shared/config/config-submission-forms.model'; import { DynamicConcatModel } from './ds-dynamic-form-ui/models/ds-dynamic-concat.model'; import { DynamicListCheckboxGroupModel } from './ds-dynamic-form-ui/models/list/dynamic-list-checkbox-group.model'; -import { DynamicGroupModel } from './ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.model'; +import { DynamicGroupModel } from './ds-dynamic-form-ui/models/dynamic-group/dynamic-group.model'; import { DynamicTagModel } from './ds-dynamic-form-ui/models/tag/dynamic-tag.model'; import { DynamicListRadioGroupModel } from './ds-dynamic-form-ui/models/list/dynamic-list-radio-group.model'; import { RowParser } from './parsers/row-parser'; @@ -135,7 +135,7 @@ export class FormBuilderService extends DynamicFormService { controlId = controlModel.name; } - const controlValue = (controlModel as any).value || null; + const controlValue = isNotUndefined((controlModel as any).value) ? (controlModel as any).value : null; if (controlId && iterateResult.hasOwnProperty(controlId) && isNotNull(iterateResult[controlId])) { iterateResult[controlId].push(controlValue); } else { @@ -151,7 +151,7 @@ export class FormBuilderService extends DynamicFormService { return result; } - modelFromConfiguration(json: string | SubmissionFormsModel, scopeUUID: string, initFormValues: any, submissionScope?: string, readOnly = false): DynamicFormControlModel[] | never { + modelFromConfiguration(json: string | SubmissionFormsModel, scopeUUID: string, initFormValues: any = {}, submissionScope?: string, readOnly = false): DynamicFormControlModel[] | never { let rows: DynamicFormControlModel[] = []; const rawData = typeof json === 'string' ? JSON.parse(json, JSONUtils.parseReviver) : json; diff --git a/src/app/shared/form/builder/parsers/date-field-parser.ts b/src/app/shared/form/builder/parsers/date-field-parser.ts index b4b7f62a9e..57e4a4cacb 100644 --- a/src/app/shared/form/builder/parsers/date-field-parser.ts +++ b/src/app/shared/form/builder/parsers/date-field-parser.ts @@ -1,9 +1,9 @@ import { FieldParser } from './field-parser'; import { DynamicDatePickerModelConfig } from '@ng-dynamic-forms/core'; import { FormFieldModel } from '../models/form-field.model'; -import { DynamicDsDatePickerModel } from '../ds-dynamic-form-ui/models/ds-date-picker/ds-date-picker.model'; +import { DynamicDsDatePickerModel } from '../ds-dynamic-form-ui/models/date-picker/date-picker.model'; import { isNotEmpty } from '../../../empty.util'; -import { DS_DATE_PICKER_SEPARATOR } from '../ds-dynamic-form-ui/models/ds-date-picker/ds-date-picker.component'; +import { DS_DATE_PICKER_SEPARATOR } from '../ds-dynamic-form-ui/models/date-picker/date-picker.component'; export class DateFieldParser extends FieldParser { diff --git a/src/app/shared/form/builder/parsers/group-field-parser.ts b/src/app/shared/form/builder/parsers/group-field-parser.ts index 5ed0dfc18b..cd897bb265 100644 --- a/src/app/shared/form/builder/parsers/group-field-parser.ts +++ b/src/app/shared/form/builder/parsers/group-field-parser.ts @@ -4,7 +4,7 @@ import { FormFieldModel } from '../models/form-field.model'; import { DynamicGroupModel, DynamicGroupModelConfig, PLACEHOLDER_PARENT_METADATA -} from '../ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.model'; +} from '../ds-dynamic-form-ui/models/dynamic-group/dynamic-group.model'; import { isNotEmpty } from '../../../empty.util'; import { FormRowModel } from '../../../../core/shared/config/config-submission-forms.model'; diff --git a/src/app/shared/form/builder/parsers/row-parser.ts b/src/app/shared/form/builder/parsers/row-parser.ts index b082cc060a..833ccfb6bd 100644 --- a/src/app/shared/form/builder/parsers/row-parser.ts +++ b/src/app/shared/form/builder/parsers/row-parser.ts @@ -11,7 +11,7 @@ import { TagFieldParser } from './tag-field-parser'; import { TextareaFieldParser } from './textarea-field-parser'; import { GroupFieldParser } from './group-field-parser'; import { IntegrationSearchOptions } from '../../../../core/integration/models/integration-options.model'; -import { DynamicGroupModel } from '../ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.model'; +import { DynamicGroupModel } from '../ds-dynamic-form-ui/models/dynamic-group/dynamic-group.model'; import { DynamicRowGroupModel } from '../ds-dynamic-form-ui/models/ds-dynamic-row-group-model'; import { isEmpty } from '../../../empty.util'; import { LookupFieldParser } from './lookup-field-parser'; diff --git a/src/app/shared/form/form.component.html b/src/app/shared/form/form.component.html index e760c0111e..0539a57000 100644 --- a/src/app/shared/form/form.component.html +++ b/src/app/shared/form/form.component.html @@ -5,6 +5,7 @@ [formId]="formId" [formGroup]="formGroup" [formModel]="formModel" + [formLayout]="formLayout" (dfBlur)="onBlur($event)" (dfChange)="onChange($event)" (dfFocus)="onFocus($event)"> diff --git a/src/app/shared/form/form.component.ts b/src/app/shared/form/form.component.ts index 47258315e2..99712bde9c 100644 --- a/src/app/shared/form/form.component.ts +++ b/src/app/shared/form/form.component.ts @@ -5,7 +5,7 @@ import { DynamicFormArrayModel, DynamicFormControlEvent, DynamicFormControlModel, - DynamicFormGroupModel, + DynamicFormGroupModel, DynamicFormLayout, } from '@ng-dynamic-forms/core'; import { Store } from '@ngrx/store'; @@ -49,6 +49,7 @@ export class FormComponent implements OnDestroy, OnInit { @Input() formModel: DynamicFormControlModel[]; @Input() parentFormModel: DynamicFormGroupModel | DynamicFormGroupModel[]; @Input() formGroup: FormGroup; + @Input() formLayout: DynamicFormLayout = null; /* tslint:disable:no-output-rename */ @Output('dfBlur') blur: EventEmitter = new EventEmitter(); @@ -205,6 +206,7 @@ export class FormComponent implements OnDestroy, OnInit { } onChange(event) { + console.log(event, this.formGroup); const action: FormChangeAction = new FormChangeAction(this.formId, this.formBuilderService.getValueFromModel(this.formModel)); this.store.dispatch(action); diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 81503f2245..d784df9df3 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -61,10 +61,10 @@ import { UploaderComponent } from './uploader/uploader.component'; import { ChipsComponent } from './chips/chips.component'; import { DsDynamicTagComponent } from './form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component'; import { DsDynamicListComponent } from './form/builder/ds-dynamic-form-ui/models/list/dynamic-list.component'; -import { DsDynamicGroupComponent } from './form/builder/ds-dynamic-form-ui/models/ds-dynamic-group/dynamic-group.components'; +import { DsDynamicGroupComponent } from './form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.components'; import { SortablejsModule } from 'angular-sortablejs'; import { NumberPickerComponent } from './number-picker/number-picker.component'; -import { DsDatePickerComponent } from './form/builder/ds-dynamic-form-ui/models/ds-date-picker/ds-date-picker.component'; +import { DsDatePickerComponent } from './form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component'; import { DsDynamicLookupComponent } from './form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component'; const MODULES = [ diff --git a/webpack/webpack.server.js b/webpack/webpack.server.js index 20f188dc79..ce0c52602a 100644 --- a/webpack/webpack.server.js +++ b/webpack/webpack.server.js @@ -17,6 +17,10 @@ module.exports = { whitelist: [ /@angular/, /@ng/, + /angular2-text-mask/, + /ng2-file-upload/, + /angular-sortablejs/, + /sortablejs/, /ngx/] })], }