[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

@@ -60,6 +60,9 @@ import { SearchApiService } from './src/services/search-api.service';
import { SharedLinksApiService } from './src/services/shared-links-api.service';
import { SitesApiService } from './src/services/sites-api.service';
export { MomentDateAdapter, MOMENT_DATE_FORMATS } from './src/utils/momentDateAdapter';
import { MomentDateAdapter } from './src/utils/momentDateAdapter';
export { ContentService } from './src/services/content.service';
export { StorageService } from './src/services/storage.service';
export { CookieService } from './src/services/cookie.service';
@@ -158,7 +161,6 @@ export function providers() {
ThumbnailService,
UploadService,
SearchService,
DeletedNodesApiService,
FavoritesApiService,
NodesApiService,
@@ -166,9 +168,12 @@ export function providers() {
SearchApiService,
SharedLinksApiService,
SitesApiService,
DiscoveryApiService,
DiscoveryApiService
];
}
// Old deprecated import
export function deprecatedProviders() {
return [
AlfrescoTranslationService,
AlfrescoAuthenticationService
];
@@ -216,7 +221,7 @@ export function createTranslateLoader(http: Http, logService: LogService) {
FileSizePipe,
HighlightPipe
],
providers: providers(),
providers: [...providers(), ...deprecatedProviders(), MomentDateAdapter],
exports: [
BrowserAnimationsModule,
CommonModule,

View File

@@ -17,7 +17,7 @@
min-width: 100px;
padding-right: 30px;
word-wrap: break-word;
color: rgb(186, 186, 186);
color: $alfresco-gray-label;
vertical-align: top;
padding-bottom: 20px;
}

View File

@@ -45,7 +45,7 @@ export abstract class CardViewBaseItemModel {
this.value = obj.value;
this.key = obj.key;
this.default = obj.default;
this.editable = obj.editable || false;
this.clickable = obj.clickable || false;
this.editable = !!obj.editable;
this.clickable = !!obj.clickable;
}
}

View File

@@ -35,7 +35,7 @@ export class CardViewTextItemModel extends CardViewBaseItemModel implements Card
constructor(obj: CardViewTextItemProperties) {
super(obj);
this.multiline = obj.multiline || false;
this.multiline = !!obj.multiline ;
}
get displayValue() {

View File

@@ -17,3 +17,4 @@
export * from './object-utils';
export * from './file-utils';
export * from './momentDateAdapter';

View File

@@ -0,0 +1,193 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DateAdapter, MdDateFormats } from '@angular/material';
import { isMoment, Moment } from 'moment';
import * as moment from 'moment';
export const MOMENT_DATE_FORMATS: MdDateFormats = {
parse: {
dateInput: 'MM-DD-YYYY'
},
display: {
dateInput: 'MM-DD-YYYY',
monthYearLabel: 'MMMM Y',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM Y'
}
};
const dateNames: string[] = [];
for (let date = 1; date <= 31; date++) {
dateNames.push(String(date));
}
export class MomentDateAdapter extends DateAdapter<Moment> {
private localeData: any = moment.localeData();
overrideDisplyaFormat: string;
getYear(date: Moment): number {
return date.year();
}
getMonth(date: Moment): number {
return date.month();
}
getDate(date: Moment): number {
return date.date();
}
getDayOfWeek(date: Moment): number {
return date.day();
}
getMonthNames(style: 'long' | 'short' | 'narrow'): string[] {
switch (style) {
case 'long':
return this.localeData.months();
case 'short':
return this.localeData.monthsShort();
case 'narrow':
return this.localeData.monthsShort().map(month => month[0]);
default :
return;
}
}
getDateNames(): string[] {
return dateNames;
}
getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[] {
switch (style) {
case 'long':
return this.localeData.weekdays();
case 'short':
return this.localeData.weekdaysShort();
case 'narrow':
return this.localeData.weekdaysShort();
default :
return;
}
}
getYearName(date: Moment): string {
return String(date.year());
}
getFirstDayOfWeek(): number {
return this.localeData.firstDayOfWeek();
}
getNumDaysInMonth(date: Moment): number {
return date.daysInMonth();
}
clone(date: Moment): Moment {
return date.clone();
}
createDate(year: number, month: number, date: number): Moment {
return moment([year, month, date]);
}
today(): Moment {
return moment();
}
parse(value: any, parseFormat: any): Moment {
let m = moment(value, parseFormat, true);
if (!m.isValid()) {
m = moment(value);
}
if (m.isValid()) {
// if user omits year, it defaults to 2001, so check for that issue.
if (m.year() === 2001 && value.indexOf('2001') === -1) {
// if 2001 not actually in the value string, change to current year
const currentYear = new Date().getFullYear();
m.set('year', currentYear);
// if date is in the future, set previous year
if (m.isAfter(moment())) {
m.set('year', currentYear - 1);
}
}
return m;
} else {
return null;
}
}
format(date: Moment, displayFormat: any): string {
displayFormat = this.overrideDisplyaFormat ? this.overrideDisplyaFormat : displayFormat;
if (date && date.format) {
return date.format(displayFormat);
} else {
return '';
}
}
addCalendarYears(date: Moment, years: number): Moment {
return date.clone().add(years, 'y');
}
addCalendarMonths(date: Moment, months: number): Moment {
return date.clone().add(months, 'M');
}
addCalendarDays(date: Moment, days: number): Moment {
return date.clone().add(days, 'd');
}
getISODateString(date: Moment): string {
return date.toISOString();
}
setLocale(locale: any): void {
this.localeData = moment.localeData(locale);
}
compareDate(first: Moment, second: Moment): number {
return first.diff(second, 'seconds', true);
}
sameDate(first: any | Moment, second: any | Moment): boolean {
if (first == null) {
// same if both null
return second == null;
} else if (isMoment(first)) {
return first.isSame(second);
} else {
const isSame = super.sameDate(first, second);
return isSame;
}
}
clampDate(date: Moment, min?: any | Moment, max?: any | Moment): Moment {
if (min && date.isBefore(min)) {
return min;
} else if (max && date.isAfter(max)) {
return max;
} else {
return date;
}
}
}