Content
View differences
Updated by Attila Dombi about 4 years ago
**As an** OpenProject user
**I want to** log time for other users
**so that** I can take over the task if the user does not have access to the system.
### **Acceptance criteria**
#### **Permissions**
* There is a separate permission to log time for another user 'Log time for other users'.
* The current permission is renamed to “Log own time.”
#### **Log time modal (default)**
In the "log time" modal:
* There is a new select field called “Resource", with autocomplete, showing all project members
* This field is only visible for users who have the 'Log time for other users' permission.
* **\[open\]** Do we have an existing word/string that is better than 'Resource' for this?
* By default, this field shows the name of the person opening the modal (current user).
* There are two buttons in the action bar at the buttom:
* "Save" (Filled/Main)
* "Cancel" (Outlined/Main)
#### **Log time modal (from "My Time Spent")**
The modal can also be called from the "My Time Spent" widget on My Page. Page.
* In this case, there is an additional "work package" field.
* The current behaviour is conserved (search field with autocomplete).
#### Time/cost report table
* There is a new column "Logged by", showing who made the entry.
* This could be a third user who has "log time for other users" permission, or the resource themselves.
* **\[open\]** Do we need to have the field added to filters and column groupings?
#### Modify logged time
A logged time can be modified.
* Clicking on the "edit" icon will show the same modal as before, with an additional button on the action bar:
* There is a delete button on the left edge:
* "Delete" (Outlined/Danger with left-icon: _delete_)
### Visuals
<figure class="image op-uc-figure"><div class="op-uc-figure--content"><img class="op-uc-image" src="/api/v3/attachments/31728/content"></div><figcaption class="op-uc-figure--description">The log time modal with Resource field</figcaption></figure>
<figure class="image op-uc-figure"><div class="op-uc-figure--content"><img class="op-uc-image" src="/api/v3/attachments/31730/content"></div><figcaption class="op-uc-figure--description">Log time, searching for a resource using autocomplete</figcaption></figure>
<figure class="image op-uc-figure"><div class="op-uc-figure--content"><img class="op-uc-image" src="/api/v3/attachments/31731/content"></div></figure>
<figure class="image op-uc-figure" style="width:50%;"><div class="op-uc-figure--content"><img class="op-uc-image" src="/api/v3/attachments/31732/content"></div><figcaption class="op-uc-figure--description"><strong>Work package</strong> field when coming from &amp;quot;My &quot;My time spent&amp;quot;</figcaption></figure>
spent&quot;</figcaption></figure>
<figure class="image op-uc-figure"><div class="op-uc-figure--content"><img class="op-uc-image" src="/api/v3/attachments/30816/content"></div><figcaption class="op-uc-figure--description">The logged time table has a new column called <strong>Logged by</strong></figcaption></figure>
<figure class="image op-uc-figure" style="width:50%;"><div class="op-uc-figure--content"><img class="op-uc-image" src="/api/v3/attachments/31733/content"></div><figcaption class="op-uc-figure--description">Delete button when editing</figcaption></figure>
All Figma screens available here:
[https://www.figma.com/file/xRFTkBJYxQJxwAf9fd3oM1/Log-time-for-others?node-id=0%3A1](https://www.figma.com/file/xRFTkBJYxQJxwAf9fd3oM1/Log-time-for-others?node-id=0%3A1)
### Technical details
**Rename "Log spent time" to "Log own time":**
* Create migration to replace the RolePermission#permission having "log\_time" with "log\_own\_time"
* Update translations
* Update the ocurrences of `:log_time` and `'log_time'` in the code with `:log_own_time`
**Add the new permission "Log time for other users":**
* Create migration to add `RolePermission#permission` "log\_time\_for\_others"
**Add a new field called logged\_by to the TimeEntry model:**
* Create a migration adding `logged_by_id` foreign key to the `TimeEntry` model, referencing the `User` model.
* Add belongs to relation, ie `belongs_to :logged_by, class_name: 'User'`
**Log time modal:**
* Create a select field called "Resources", which will reference the `TimeEntry#user_id` `TimeEntry#logged_by_id` field
* Populate it with all the available users for the project using the `API::V3::Projects::AvailableAssigneesAPI` endpoint
* Show it only when the current user has the permission `"log_time_for_others"`
* Use the `WorkPackageAuthorization` service to fetch permission to add time for others.
(See for example https://github.com/opf/openproject/blob/32da00108d89fc4e28c4b06ec77385beedc9ba81/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-single-context-menu.ts#L44-L45)
* The visual changes can be implemented later on, when the new design systems are in place. A follow up with the design team (Ben, Henriette) is required when starting on this feature.
* Most of the things are accessible already by visiting `/design/spot`.
* A few notable elements missing:
* A dropdown for picking users
* The label+input errors
* A main spot container that will align all the form elements with equal spacing.
**Time/cost report table:**
* Add a new field `:logged_by` to the `::Widget::Table::EntryTable::FIELDS` constant
(./modules/reporting/lib/widget/table/entry\_table.rb)
* Update the method `field_representation_map` and expand the `when :user_id, :assigned_to_id, :author_id` with `:logged_by_id` in the `ReportingHelper` module.
(./modules/reporting/app/helpers/reporting\_helper.rb)
* "Cancel" (Outlined/Main)
**I want to** log time for other users
**so that** I can take over the task if the user does not have access to the system.
### **Acceptance criteria**
#### **Permissions**
* There is a separate permission to log time for another user 'Log time for other users'.
* The current permission is renamed to “Log own time.”
#### **Log time modal (default)**
In the "log time" modal:
* There is a new select field called “Resource", with autocomplete, showing all project members
* This field is only visible for users who have the 'Log time for other users' permission.
* **\[open\]** Do we have an existing word/string that is better than 'Resource' for this?
* By default, this field shows the name of the person opening the modal (current user).
* There are two buttons in the action bar at the buttom:
* "Save" (Filled/Main)
* "Cancel" (Outlined/Main)
#### **Log time modal (from "My Time Spent")**
The modal can also be called from the "My Time Spent" widget on My Page.
* In this case, there is an additional "work package" field.
* The current behaviour is conserved (search field with autocomplete).
#### Time/cost report table
* There is a new column "Logged by", showing who made the entry.
* This could be a third user who has "log time for other users" permission, or the resource themselves.
* **\[open\]** Do we need to have the field added to filters and column groupings?
#### Modify logged time
A logged time can be modified.
* Clicking on the "edit" icon will show the same modal as before, with an additional button on the action bar:
* There is a delete button on the left edge:
* "Delete" (Outlined/Danger with left-icon: _delete_)
### Visuals
<figure class="image op-uc-figure"><div class="op-uc-figure--content"><img class="op-uc-image" src="/api/v3/attachments/31728/content"></div><figcaption class="op-uc-figure--description">The log time modal with Resource field</figcaption></figure>
<figure class="image op-uc-figure"><div class="op-uc-figure--content"><img class="op-uc-image" src="/api/v3/attachments/31730/content"></div><figcaption class="op-uc-figure--description">Log time, searching for a resource using autocomplete</figcaption></figure>
<figure class="image op-uc-figure"><div class="op-uc-figure--content"><img class="op-uc-image" src="/api/v3/attachments/31731/content"></div></figure>
[https://www.figma.com/file/xRFTkBJYxQJxwAf9fd3oM1/Log-time-for-others?node-id=0%3A1](https://www.figma.com/file/xRFTkBJYxQJxwAf9fd3oM1/Log-time-for-others?node-id=0%3A1)
### Technical details
**Rename "Log spent time" to "Log own time":**
* Create migration to replace the RolePermission#permission having "log\_time" with "log\_own\_time"
* Update translations
* Update the ocurrences of `:log_time` and `'log_time'` in the code with `:log_own_time`
**Add the new permission "Log time for other users":**
* Create migration to add `RolePermission#permission` "log\_time\_for\_others"
**Add a new field called logged\_by to the TimeEntry model:**
* Create a migration adding `logged_by_id` foreign key to the `TimeEntry` model, referencing the `User` model.
* Add belongs to relation, ie `belongs_to :logged_by, class_name: 'User'`
**Log time modal:**
* Create a select field called "Resources", which will reference the `TimeEntry#user_id`
* Populate it with all the available users for the project using the `API::V3::Projects::AvailableAssigneesAPI` endpoint
* Show it only when the current user has the permission `"log_time_for_others"`
* Use the `WorkPackageAuthorization` service to fetch permission to add time for others.
(See for example https://github.com/opf/openproject/blob/32da00108d89fc4e28c4b06ec77385beedc9ba81/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-single-context-menu.ts#L44-L45)
* The visual changes can be implemented later on, when the new design systems are in place. A follow up with the design team (Ben, Henriette) is required when starting on this feature.
* Most of the things are accessible already by visiting `/design/spot`.
* A few notable elements missing:
* A dropdown for picking users
* The label+input errors
* A main spot container that will align all the form elements with equal spacing.
**Time/cost report table:**
* Add a new field `:logged_by` to the `::Widget::Table::EntryTable::FIELDS` constant
(./modules/reporting/lib/widget/table/entry\_table.rb)
* Update the method `field_representation_map` and expand the `when :user_id, :assigned_to_id, :author_id` with `:logged_by_id` in the `ReportingHelper` module.
(./modules/reporting/app/helpers/reporting\_helper.rb)
* "Cancel" (Outlined/Main)