Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

have time entry edit modal in edit mode

ulferts79ea17610ca4
diff --git a/frontend/src/app/modules/time_entries/create/create.modal.html b/frontend/src/app/modules/time_entries/create/create.modal.html
index 9ba9fb16b2b..8e61b4bfad5 100644
--- a/frontend/src/app/modules/time_entries/create/create.modal.html
+++ b/frontend/src/app/modules/time_entries/create/create.modal.html
@@ -23,14 +23,20 @@
<div class="op-modal--modal-footer">
<button class="button -highlight"
(click)="createEntry()"
- [textContent]="text.create"
[attr.title]="text.create">
+ <op-icon icon-classes="button--icon icon-checkmark"></op-icon>
+ <span class="button--text"
+ [textContent]="text.create"
+ aria-hidden="true"></span>
</button>
<button class="button"
(click)="closeMe($event)"
- [textContent]="text.cancel"
[attr.title]="text.cancel">
+ <op-icon icon-classes="button--icon icon-close"></op-icon>
+ <span class="button--text"
+ [textContent]="text.cancel"
+ aria-hidden="true"></span>
</button>
</div>
</div>
diff --git a/frontend/src/app/modules/time_entries/edit/edit.modal.html b/frontend/src/app/modules/time_entries/edit/edit.modal.html
index 59501841e3f..d097744d079 100644
--- a/frontend/src/app/modules/time_entries/edit/edit.modal.html
+++ b/frontend/src/app/modules/time_entries/edit/edit.modal.html
@@ -14,16 +14,31 @@
</div>
<div class="ngdialog-body op-modal--modal-body">
- <te-form [entry]="entry"
+ <te-form #editForm
+ [entry]="entry"
(modifiedEntry)="setModifiedEntry($event)">
</te-form>
</div>
<div class="op-modal--modal-footer">
<button class="button -highlight"
+ *ngIf="updateAllowed"
+ (click)="saveEntry()"
+ [attr.title]="text.save">
+ <op-icon icon-classes="button--icon icon-checkmark"></op-icon>
+ <span class="button--text"
+ [textContent]="text.save"
+ aria-hidden="true"></span>
+ </button>
+
+ <button class="button"
+ *ngIf="updateAllowed"
(click)="closeMe($event)"
- [textContent]="text.close"
- [attr.title]="text.close">
+ [attr.title]="text.cancel">
+ <op-icon icon-classes="button--icon icon-close"></op-icon>
+ <span class="button--text"
+ [textContent]="text.cancel"
+ aria-hidden="true"></span>
</button>
<button class="button"
diff --git a/frontend/src/app/modules/time_entries/edit/edit.modal.ts b/frontend/src/app/modules/time_entries/edit/edit.modal.ts
index 98db0eb45d1..ba09cd52d60 100644
--- a/frontend/src/app/modules/time_entries/edit/edit.modal.ts
+++ b/frontend/src/app/modules/time_entries/edit/edit.modal.ts
@@ -1,4 +1,4 @@
-import {Component, ElementRef, Inject, ChangeDetectorRef, ChangeDetectionStrategy} from "@angular/core";
+import {Component, ElementRef, Inject, ChangeDetectorRef, ChangeDetectionStrategy, ViewChild} from "@angular/core";
import {OpModalComponent} from "app/components/op-modals/op-modal.component";
import {OpModalLocalsToken} from "app/components/op-modals/op-modal.service";
import {OpModalLocalsMap} from "app/components/op-modals/op-modal.types";
@@ -6,6 +6,7 @@ import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {HalResourceEditingService} from "core-app/modules/fields/edit/services/hal-resource-editing.service";
import {TimeEntryResource} from "core-app/modules/hal/resources/time-entry-resource";
import {HalResource} from "core-app/modules/hal/resources/hal-resource";
+import {TimeEntryFormComponent} from "core-app/modules/time_entries/form/form.component";
@Component({
templateUrl: './edit.modal.html',
@@ -17,10 +18,14 @@ import {HalResource} from "core-app/modules/hal/resources/hal-resource";
})
export class TimeEntryEditModal extends OpModalComponent {
+ @ViewChild('editForm', { static: true }) editForm:TimeEntryFormComponent;
+
text = {
title: this.i18n.t('js.time_entry.label'),
- close: this.i18n.t('js.button_close'),
- delete: this.i18n.t('js.button_delete')
+ save: this.i18n.t('js.button_save'),
+ delete: this.i18n.t('js.button_delete'),
+ cancel: this.i18n.t('js.button_cancel'),
+ close: this.i18n.t('js.button_close')
};
public closeOnEscape = false;
@@ -44,6 +49,17 @@ export class TimeEntryEditModal extends OpModalComponent {
this.modifiedEntry = $event.savedResource as TimeEntryResource;
}
+ public saveEntry() {
+ this.editForm.save()
+ .then(() => {
+ this.service.close();
+ });
+ }
+
+ public get updateAllowed() {
+ return !!this.entry.update;
+ }
+
public get deleteAllowed() {
return !!this.entry.delete;
}
diff --git a/frontend/src/app/modules/time_entries/form/form.component.ts b/frontend/src/app/modules/time_entries/form/form.component.ts
index 87491dc2241..65f7d2e50ac 100644
--- a/frontend/src/app/modules/time_entries/form/form.component.ts
+++ b/frontend/src/app/modules/time_entries/form/form.component.ts
@@ -69,7 +69,9 @@ export class TimeEntryFormComponent implements OnInit, OnDestroy {
}
public get inEditMode() {
- return this.entry.isNew;
+ // For now, we always want the form in edit mode.
+ // Alternatively, this.entry.isNew can be used.
+ return true;
}
public isRequired(field:string) {
diff --git a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
index bb2018f6ae9..57ab7815f4f 100644
--- a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
+++ b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
@@ -217,35 +217,19 @@ describe 'My page time entries current user widget spec', type: :feature, js: tr
expect(page)
.to have_content(I18n.t('js.time_entry.label'))
- activity_field.activate!
+ activity_field.input_element.click
activity_field.set_value(other_activity.name)
- activity_field.expect_display_value(other_activity.name)
- wp_field.activate!
+ wp_field.input_element.click
wp_field.set_value(other_work_package.subject)
- wp_field.expect_display_value(other_work_package.name)
- hours_field.activate!
hours_field.set_value('6')
- hours_field.save!
-
- hours_field.expect_display_value('6 h')
- comments_field.activate!
comments_field.set_value('Some comment')
- comments_field.save!
- comments_field.expect_display_value('Some comment')
-
- cf_field.activate!
cf_field.set_value('Cf text value')
- cf_field.save!
-
- cf_field.expect_display_value('Cf text value')
-
- sleep(1)
- find(".op-modal--portal .op-modal--modal-close-button").click
+ click_button 'Save'
sleep(0.1)
my_page.expect_and_dismiss_notification message: I18n.t(:notice_successful_update)
@@ -255,11 +239,17 @@ describe 'My page time entries current user widget spec', type: :feature, js: tr
end
expect(page)
- .to have_selector('.ui-tooltip', text: "Comment: Some comment")
+ .to have_selector('.ui-tooltip', text: "Work package: ##{other_work_package.id}: #{other_work_package.subject}")
+
+ expect(page)
+ .to have_selector('.ui-tooltip', text: "Duration: 6 h")
expect(page)
.to have_selector('.ui-tooltip', text: "Activity: #{other_activity.name}")
+ expect(page)
+ .to have_selector('.ui-tooltip', text: "Comment: Some comment")
+
expect(page)
.to have_content "Total: 12.00"