Merge pull request #8435 from opf/feature/my_spent_time_config
allow hiding days on the logged time widget [ci skip]pull/8440/head
commit
16fe9da921
@ -0,0 +1,38 @@ |
||||
<div class="op-modal--portal "> |
||||
<div class="op-modal--modal-container" |
||||
data-indicator-name="modal" |
||||
tabindex="0"> |
||||
<div class="op-modal--modal-header"> |
||||
<a class="op-modal--modal-close-button"> |
||||
<i |
||||
class="icon-close" |
||||
(click)="closeMe($event)" |
||||
[attr.title]="text.closePopup"> |
||||
</i> |
||||
</a> |
||||
</div> |
||||
|
||||
<h3 [textContent]="text.displayedDays"></h3> |
||||
|
||||
<div class="form--field -trailing-label" *ngFor="let day of text.weekdays; let index = index"> |
||||
<label class="form--label" [textContent]="day" [htmlFor]="'day_' + index"></label> |
||||
<span class="form--field-container"> |
||||
<span class="form--check-box-container"> |
||||
<input type="checkbox" [id]="'day_' + index" name="days" class="form--check-box" [(ngModel)]="days[index]"> |
||||
</span> |
||||
</span> |
||||
</div> |
||||
|
||||
<div class="tab-content"></div> |
||||
<div class="modal--form-actions"> |
||||
<button class="button -highlight" |
||||
[textContent]="text.applyButton" |
||||
(click)="saveChanges()"> |
||||
</button> |
||||
<button class="button" |
||||
[textContent]="text.cancelButton" |
||||
(click)="closeMe($event)"> |
||||
</button> |
||||
</div> |
||||
</div> |
||||
</div> |
@ -0,0 +1,85 @@ |
||||
import { |
||||
ApplicationRef, |
||||
ChangeDetectorRef, |
||||
Component, |
||||
ComponentFactoryResolver, |
||||
ElementRef, |
||||
Inject, |
||||
InjectionToken, |
||||
Injector, |
||||
OnDestroy, |
||||
OnInit, |
||||
Optional, |
||||
ViewChild |
||||
} from '@angular/core'; |
||||
import {OpModalLocalsMap} from 'core-components/op-modals/op-modal.types'; |
||||
import {ConfigurationService} from 'core-app/modules/common/config/configuration.service'; |
||||
import {OpModalComponent} from 'core-components/op-modals/op-modal.component'; |
||||
import { |
||||
ActiveTabInterface, |
||||
TabComponent, |
||||
TabInterface, |
||||
TabPortalOutlet |
||||
} from 'core-components/wp-table/configuration-modal/tab-portal-outlet'; |
||||
import {LoadingIndicatorService} from 'core-app/modules/common/loading-indicator/loading-indicator.service'; |
||||
import {I18nService} from "core-app/modules/common/i18n/i18n.service"; |
||||
import {OpModalLocalsToken} from "core-components/op-modals/op-modal.service"; |
||||
import {ComponentType} from "@angular/cdk/portal"; |
||||
import {WpGraphConfigurationService} from "core-app/modules/work-package-graphs/configuration/wp-graph-configuration.service"; |
||||
import {WpGraphConfiguration} from "core-app/modules/work-package-graphs/configuration/wp-graph-configuration"; |
||||
import {WorkPackageNotificationService} from "core-app/modules/work_packages/notifications/work-package-notification.service"; |
||||
|
||||
@Component({ |
||||
templateUrl: './time-entries-current-user-configuration.modal.html', |
||||
}) |
||||
export class TimeEntriesCurrentUserConfigurationModalComponent extends OpModalComponent implements OnInit { |
||||
|
||||
/* Close on escape? */ |
||||
public closeOnEscape = true; |
||||
|
||||
/* Close on outside click */ |
||||
public closeOnOutsideClick = true; |
||||
|
||||
public $element:JQuery; |
||||
|
||||
public text = { |
||||
displayedDays: this.I18n.t('js.grid.widgets.time_entries_current_user.displayed_days'), |
||||
closePopup: this.I18n.t('js.close_popup_title'), |
||||
|
||||
applyButton: this.I18n.t('js.modals.button_apply'), |
||||
cancelButton: this.I18n.t('js.modals.button_cancel'), |
||||
|
||||
weekdays: moment.weekdays() |
||||
}; |
||||
|
||||
public firstDayOfWeek:number; |
||||
public firstDayOffset = this.configuration.startOfWeek(); |
||||
|
||||
// All days of the week, zero based on Monday.
|
||||
public options:{ days:boolean[] }; |
||||
public days:boolean[]; |
||||
|
||||
constructor(@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap, |
||||
readonly I18n:I18nService, |
||||
readonly injector:Injector, |
||||
readonly appRef:ApplicationRef, |
||||
readonly loadingIndicator:LoadingIndicatorService, |
||||
readonly notificationService:WorkPackageNotificationService, |
||||
readonly cdRef:ChangeDetectorRef, |
||||
readonly configuration:ConfigurationService, |
||||
readonly elementRef:ElementRef) { |
||||
super(locals, cdRef, elementRef); |
||||
} |
||||
|
||||
ngOnInit() { |
||||
this.days = this.locals.options.days || Array.from({ length: 7 }, () => true ); |
||||
|
||||
let momentFirstDayOffset = 1 + moment.localeData().firstDayOfWeek() % 7; |
||||
this.text.weekdays = moment.localeData().weekdays().slice(momentFirstDayOffset).concat(moment.localeData().weekdays().slice(0, momentFirstDayOffset)); |
||||
} |
||||
|
||||
public saveChanges():void { |
||||
this.options = { days: this.days }; |
||||
this.service.close(); |
||||
} |
||||
} |
@ -0,0 +1,81 @@ |
||||
//-- copyright
|
||||
// OpenProject is an open source project management software.
|
||||
// Copyright (C) 2012-2020 the OpenProject GmbH
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See docs/COPYRIGHT.rdoc for more details.
|
||||
//++
|
||||
|
||||
import {Component, Output, EventEmitter, Injector} from '@angular/core'; |
||||
import {WpGraphConfigurationModalComponent} from "core-app/modules/work-package-graphs/configuration-modal/wp-graph-configuration.modal"; |
||||
import {WidgetWpSetMenuComponent} from "core-app/modules/grids/widgets/menu/wp-set-menu.component"; |
||||
import {OpModalComponent} from "core-components/op-modals/op-modal.component"; |
||||
import {OpModalService} from "core-components/op-modals/op-modal.service"; |
||||
import {I18nService} from "core-app/modules/common/i18n/i18n.service"; |
||||
import {GridRemoveWidgetService} from "core-app/modules/grids/grid/remove-widget.service"; |
||||
import {GridAreaService} from "core-app/modules/grids/grid/area.service"; |
||||
import {WidgetAbstractMenuComponent} from "core-app/modules/grids/widgets/menu/widget-abstract-menu.component"; |
||||
import {TimeEntriesCurrentUserConfigurationModalComponent} from "core-app/modules/grids/widgets/time-entries/current-user/time-entries-current-user-configuration.modal"; |
||||
|
||||
@Component({ |
||||
selector: 'widget-time-entries-current-user-menu', |
||||
templateUrl: '../../menu/widget-menu.component.html' |
||||
}) |
||||
export class WidgetTimeEntriesCurrentUserMenuComponent extends WidgetAbstractMenuComponent { |
||||
@Output() |
||||
onConfigured:EventEmitter<any> = new EventEmitter(); |
||||
|
||||
protected menuItemList = [ |
||||
this.removeItem, |
||||
this.configureItem |
||||
]; |
||||
|
||||
constructor(private readonly injector:Injector, |
||||
private readonly opModalService:OpModalService, |
||||
readonly i18n:I18nService, |
||||
protected readonly remove:GridRemoveWidgetService, |
||||
readonly layout:GridAreaService) { |
||||
super(i18n, |
||||
remove, |
||||
layout); |
||||
} |
||||
|
||||
protected get configureItem() { |
||||
return { |
||||
linkText: this.i18n.t('js.grid.configure'), |
||||
onClick: () => { |
||||
this.opModalService.show(TimeEntriesCurrentUserConfigurationModalComponent, this.injector, this.locals) |
||||
.closingEvent.subscribe((modal:TimeEntriesCurrentUserConfigurationModalComponent) => { |
||||
if (modal.options) { |
||||
this.onConfigured.emit(modal.options); |
||||
} |
||||
}); |
||||
return true; |
||||
} |
||||
}; |
||||
} |
||||
|
||||
protected get locals() { |
||||
return { options: this.resource.options }; |
||||
} |
||||
} |
@ -0,0 +1,42 @@ |
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2020 the OpenProject GmbH |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
module API |
||||
module V3 |
||||
module Grids |
||||
module Widgets |
||||
class TimeEntryCalendarOptionsRepresenter < DefaultOptionsRepresenter |
||||
property :days, |
||||
getter: ->(represented:, **) { |
||||
represented['days'] || {} |
||||
} |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue