[ADF-852] Form style Material 2 (#2151)

* mdl2 transition part form 1

* hyperlink

* radio buttons

* label

* people component

* [ADF-852] moved textarea to new angular material

* number widget

* change error multiline

* [ADF-852] added md desgin for dropdown

* [ADF-852] removed unused css file

* functional widget

* error dropdown

* [ADF-852] - changed to new md date

* remove md-date-time-picker dependency in ng2-alfresco-from

* [ADF-852] conversion dynamic table phase 1

* container widget

* remove test unused

* validation change

* [ADF-852] convert dynamic table phase 2

* [ADF-852] improving style and fixing bugs

* move custom style for form in form.scss

* error footer refactor

* fix models and test

* [ADF-852]- fixed minor twitch on dynamic table

* align fields and fix tests dropdown

* disabling button in readonly
clean mdl form start process form

* align dropdown

* [ADF-1048] Upload widget can manage multiple files. (#2134)

* [ADF-1048] improving upload widget

* [ADF-1048] added ability to upload multiple file on upload widget

* [ADF-1048] added multiple upload elements on upload widget

* [ADF-1048] - show all the files on the completed form

* [ADF-1048] fixed wrong selecion on displya upload

* [ADF-1048] removed fdescribe from upload widget

* date validation and custom moment data adapter

* move content widget in the widget folder

* add style fields and theming

* color primary radio and checkbox

* fix amount widget and colors

* change ViewEncapsulation and fix date style button issue

* empty form customization 1736

* focus label style

* [ADF-224] fix the rendering of custom stencils when form is opened in readonly state. (#2161)

* [ADF-224] Fixed rendering of custom stencil in readonly mode

* [ADF-224] improved variable name

* test fix

* container filter in form model creation

* show display value correctly

* fix change date and test

* fix date editor and add some test coverage for date

* style minor issue

* fix new unused local import rule

* fix test date

* strict date check

* fix analytics failing test

* restore null as default in model

* unify model diagrams and analytics
This commit is contained in:
Eugenio Romano
2017-08-07 13:15:29 +01:00
committed by Mario Romano
parent 47ea517ffb
commit 083c9da0d4
197 changed files with 10201 additions and 4774 deletions

View File

@@ -15,28 +15,31 @@
* limitations under the License.
*/
/* tslint:disable:component-selector */
/* tslint:disable:component-selector */
import { Component, OnInit } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { LogService, ThumbnailService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { FormService } from '../../../services/form.service';
import { baseHost, WidgetComponent } from './../widget.component';
@Component({
selector: 'upload-widget',
templateUrl: './upload.widget.html',
styleUrls: ['./upload.widget.css'],
host: baseHost
styleUrls: ['./upload.widget.scss'],
host: baseHost,
encapsulation: ViewEncapsulation.None
})
export class UploadWidgetComponent extends WidgetComponent implements OnInit {
hasFile: boolean;
fileName: string;
displayText: string;
multipleOption: string = '';
mimeTypeIcon: string;
constructor(public formService: FormService,
private logService: LogService) {
private logService: LogService,
private thumbnailService: ThumbnailService) {
super(formService);
}
@@ -45,39 +48,45 @@ export class UploadWidgetComponent extends WidgetComponent implements OnInit {
this.field.value &&
this.field.value.length > 0) {
this.hasFile = true;
let file = this.field.value[0];
this.fileName = file.name;
this.displayText = decodeURI(file.name);
}
this.getMultipleFileParam();
}
reset() {
this.hasFile = false;
this.fileName = null;
this.displayText = null;
reset(file: any) {
if (this.field) {
this.field.value = null;
this.field.json.value = null;
this.removeElementFromList(this.field.value, file);
this.removeElementFromList(this.field.json.value, file);
this.hasFile = this.field.value.length > 0;
this.resetFormValueWithNoFiles();
}
}
onFileChanged(event: any) {
let files = event.target.files;
let filesSaved = [];
if (files && files.length > 0) {
let file = files[0];
this.formService.createTemporaryRawRelatedContent(file)
.subscribe((response: any) => {
this.logService.info(response);
this.field.value = [response];
this.field.json.value = [response];
}, (error: any) => {
Observable.from(files).
flatMap(file => this.uploadRawContent(file)).subscribe((res) => {
filesSaved.push(res);
},
(error) => {
this.logService.error('Error uploading file. See console output for more details.');
},
() => {
this.field.value = filesSaved;
this.field.json.value = filesSaved;
});
}
}
private uploadRawContent(file): Observable<any> {
return this.formService.createTemporaryRawRelatedContent(file)
.map((response: any) => {
this.logService.info(response);
return response;
});
}
private getMultipleFileParam() {
if (this.field &&
this.field.params &&
@@ -86,4 +95,26 @@ export class UploadWidgetComponent extends WidgetComponent implements OnInit {
}
}
decode(fileName: string): string {
return decodeURI(fileName);
}
private removeElementFromList(list, element) {
let index = list.indexOf(element);
if (index !== -1) {
list.splice(index, 1);
}
}
private resetFormValueWithNoFiles() {
if (this.field.value.length === 0) {
this.field.value = null;
this.field.json.value = null;
}
}
getIcon(mimeType) {
return this.thumbnailService.getMimeTypeIcon(mimeType);
}
}