mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
#632 basic date picker dialog
This commit is contained in:
parent
c77fe0cb53
commit
79fa74388a
@ -63,6 +63,7 @@
|
||||
|
||||
"ng2-translate": "2.5.0",
|
||||
"moment": "2.15.1",
|
||||
"md-date-time-picker": "^2.2.0",
|
||||
|
||||
"alfresco-js-api": "^0.3.0",
|
||||
"ng2-alfresco-core": "0.3.2"
|
||||
|
@ -2,6 +2,10 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.date-widget--button {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.date-widget__invalid .mdl-textfield__input {
|
||||
border-color: #d50000;
|
||||
}
|
||||
|
@ -1,12 +1,25 @@
|
||||
<div class="mdl-grid">
|
||||
<div class="mdl-cell mdl-cell--11-col">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label date-widget"
|
||||
[class.date-widget__invalid]="!field.isValid">
|
||||
<input class="mdl-textfield__input"
|
||||
<input id="dateInput"
|
||||
class="mdl-textfield__input"
|
||||
type="text"
|
||||
[attr.id]="field.id"
|
||||
[attr.required]="isRequired()"
|
||||
[(ngModel)]="field.value"
|
||||
(ngModelChange)="checkVisibility(field)"
|
||||
(ngModelChange)="onDateChanged()"
|
||||
(onOk)="onDateSelected()"
|
||||
[disabled]="field.readOnly">
|
||||
<label class="mdl-textfield__label" [attr.for]="field.id">{{field.name}} (d-M-yyyy)</label>
|
||||
<span *ngIf="field.validationSummary" class="mdl-textfield__error">{{field.validationSummary}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mdl-cell mdl-cell--1-col">
|
||||
<button
|
||||
class="mdl-button mdl-js-button mdl-button--icon date-widget--button"
|
||||
(click)="datePicker.toggle()">
|
||||
<i class="material-icons">date_range</i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, ElementRef } from '@angular/core';
|
||||
import { Component, ElementRef, OnInit } from '@angular/core';
|
||||
import { TextFieldWidgetComponent } from './../textfield-widget.component';
|
||||
|
||||
@Component({
|
||||
@ -24,10 +24,33 @@ import { TextFieldWidgetComponent } from './../textfield-widget.component';
|
||||
templateUrl: './date.widget.html',
|
||||
styleUrls: ['./date.widget.css']
|
||||
})
|
||||
export class DateWidget extends TextFieldWidgetComponent {
|
||||
export class DateWidget extends TextFieldWidgetComponent implements OnInit {
|
||||
|
||||
datePicker: any = new mdDateTimePicker.default({
|
||||
type: 'date',
|
||||
future: moment().add(21, 'years')
|
||||
});
|
||||
|
||||
constructor(elementRef: ElementRef) {
|
||||
super(elementRef);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.field.value) {
|
||||
this.datePicker.time = moment(this.field.value, 'D-M-YYYY');
|
||||
}
|
||||
this.datePicker.trigger = this.elementRef.nativeElement.querySelector('#dateInput');
|
||||
}
|
||||
|
||||
onDateChanged() {
|
||||
if (this.field.value) {
|
||||
this.datePicker.time = moment(this.field.value, 'D-M-YYYY');
|
||||
}
|
||||
this.checkVisibility(this.field);
|
||||
}
|
||||
|
||||
onDateSelected() {
|
||||
this.field.value = this.datePicker.time.format('DD-MM-YYYY');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
declare var module: any;
|
||||
declare var moment: any;
|
||||
declare let mdDateTimePicker: any;
|
||||
|
||||
// MDL
|
||||
declare var componentHandler: any;
|
||||
|
Loading…
x
Reference in New Issue
Block a user