This was planned for the initial breakup of single and multi modal, but was forgotten. Fixes https://community.openproject.org/wp/44119pull/11283/head
parent
6bbafcb43f
commit
f65d643982
@ -0,0 +1,15 @@ |
||||
<div class="form--field"> |
||||
<label class="form--label"> |
||||
{{text.scheduling.title}} |
||||
</label> |
||||
<div class="form--field-container"> |
||||
<spot-toggle |
||||
[options]="schedulingOptions" |
||||
[value]="scheduleManually" |
||||
[name]="'scheduling'" |
||||
[ngModel]="scheduleManually" |
||||
(ngModelChange)="onToggle($event)" |
||||
data-qa-selector="op-datepicker-modal--scheduling-action" |
||||
></spot-toggle> |
||||
</div> |
||||
</div> |
@ -0,0 +1,67 @@ |
||||
import { |
||||
ChangeDetectionStrategy, |
||||
ChangeDetectorRef, |
||||
Component, |
||||
forwardRef, |
||||
Input, |
||||
} from '@angular/core'; |
||||
import { I18nService } from 'core-app/core/i18n/i18n.service'; |
||||
import { |
||||
ControlValueAccessor, |
||||
NG_VALUE_ACCESSOR, |
||||
} from '@angular/forms'; |
||||
|
||||
@Component({ |
||||
selector: 'op-datepicker-scheduling-toggle', |
||||
templateUrl: './datepicker-scheduling-toggle.component.html', |
||||
changeDetection: ChangeDetectionStrategy.OnPush, |
||||
providers: [{ |
||||
provide: NG_VALUE_ACCESSOR, |
||||
useExisting: forwardRef(() => DatepickerSchedulingToggleComponent), |
||||
multi: true, |
||||
}], |
||||
}) |
||||
export class DatepickerSchedulingToggleComponent implements ControlValueAccessor { |
||||
text = { |
||||
scheduling: { |
||||
title: this.I18n.t('js.scheduling.title'), |
||||
manual: this.I18n.t('js.scheduling.manual'), |
||||
default: this.I18n.t('js.scheduling.default'), |
||||
}, |
||||
}; |
||||
|
||||
@Input() scheduleManually:boolean; |
||||
|
||||
schedulingOptions = [ |
||||
{ value: false, title: this.text.scheduling.default }, |
||||
{ value: true, title: this.text.scheduling.manual }, |
||||
]; |
||||
|
||||
constructor( |
||||
private I18n:I18nService, |
||||
private cdRef:ChangeDetectorRef, |
||||
) { } |
||||
|
||||
onChange = (_:boolean):void => {}; |
||||
|
||||
onTouched = (_:boolean):void => {}; |
||||
|
||||
registerOnChange(fn:(_:boolean) => void):void { |
||||
this.onChange = fn; |
||||
} |
||||
|
||||
registerOnTouched(fn:(_:boolean) => void):void { |
||||
this.onTouched = fn; |
||||
} |
||||
|
||||
writeValue(val:boolean):void { |
||||
this.scheduleManually = val; |
||||
this.cdRef.markForCheck(); |
||||
} |
||||
|
||||
onToggle(value:boolean):void { |
||||
this.writeValue(value); |
||||
this.onChange(value); |
||||
this.onTouched(value); |
||||
} |
||||
} |
@ -0,0 +1,15 @@ |
||||
<div class="form--field"> |
||||
<label class="form--label"> |
||||
{{ text.ignoreNonWorkingDays.title }} |
||||
</label> |
||||
<div class="form--field-container"> |
||||
<spot-toggle |
||||
[options]="ignoreNonWorkingDaysOptions" |
||||
[value]="ignoreNonWorkingDays" |
||||
[name]="'include-non-working-days'" |
||||
[ngModel]="ignoreNonWorkingDays" |
||||
(ngModelChange)="onToggle($event)" |
||||
data-qa-selector="op-datepicker-modal--include-non-working-days" |
||||
></spot-toggle> |
||||
</div> |
||||
</div> |
@ -0,0 +1,67 @@ |
||||
import { |
||||
ChangeDetectionStrategy, |
||||
ChangeDetectorRef, |
||||
Component, |
||||
forwardRef, |
||||
Input, |
||||
} from '@angular/core'; |
||||
import { I18nService } from 'core-app/core/i18n/i18n.service'; |
||||
import { |
||||
ControlValueAccessor, |
||||
NG_VALUE_ACCESSOR, |
||||
} from '@angular/forms'; |
||||
|
||||
@Component({ |
||||
selector: 'op-datepicker-working-days-toggle', |
||||
templateUrl: './datepicker-working-days-toggle.component.html', |
||||
changeDetection: ChangeDetectionStrategy.OnPush, |
||||
providers: [{ |
||||
provide: NG_VALUE_ACCESSOR, |
||||
useExisting: forwardRef(() => DatepickerWorkingDaysToggleComponent), |
||||
multi: true, |
||||
}], |
||||
}) |
||||
export class DatepickerWorkingDaysToggleComponent implements ControlValueAccessor { |
||||
@Input() ignoreNonWorkingDays:boolean; |
||||
|
||||
text = { |
||||
ignoreNonWorkingDays: { |
||||
title: this.I18n.t('js.work_packages.datepicker_modal.ignore_non_working_days.title'), |
||||
yes: this.I18n.t('js.work_packages.datepicker_modal.ignore_non_working_days.true'), |
||||
no: this.I18n.t('js.work_packages.datepicker_modal.ignore_non_working_days.false'), |
||||
}, |
||||
}; |
||||
|
||||
ignoreNonWorkingDaysOptions = [ |
||||
{ value: false, title: this.text.ignoreNonWorkingDays.no }, |
||||
{ value: true, title: this.text.ignoreNonWorkingDays.yes }, |
||||
]; |
||||
|
||||
constructor( |
||||
private I18n:I18nService, |
||||
private cdRef:ChangeDetectorRef, |
||||
) {} |
||||
|
||||
onChange = (_:boolean):void => {}; |
||||
|
||||
onTouched = (_:boolean):void => {}; |
||||
|
||||
registerOnChange(fn:(_:boolean) => void):void { |
||||
this.onChange = fn; |
||||
} |
||||
|
||||
registerOnTouched(fn:(_:boolean) => void):void { |
||||
this.onTouched = fn; |
||||
} |
||||
|
||||
onToggle(value:boolean):void { |
||||
this.writeValue(value); |
||||
this.onChange(value); |
||||
this.onTouched(value); |
||||
} |
||||
|
||||
writeValue(val:boolean):void { |
||||
this.ignoreNonWorkingDays = val; |
||||
this.cdRef.markForCheck(); |
||||
} |
||||
} |
Loading…
Reference in new issue