diff --git a/app/locales/locale-en.json b/app/locales/locale-en.json index b619d1fc..7bee2fed 100644 --- a/app/locales/locale-en.json +++ b/app/locales/locale-en.json @@ -1239,9 +1239,13 @@ "NEW_PROJECT": "{{username}} created the project {{project_name}}", "MILESTONE_UPDATED": "{{username}} has updated the sprint {{obj_name}}", "US_UPDATED": "{{username}} has updated the attribute \"{{field_name}}\" of the US {{obj_name}}", + "US_UPDATED_WITH_NEW_VALUE": "{{username}} has updated the attribute \"{{field_name}}\" of the US {{obj_name}} to {{new_value}}", "ISSUE_UPDATED": "{{username}} has updated the attribute \"{{field_name}}\" of the issue {{obj_name}}", - "TASK_UPDATED": "{{username}} has updated the attribute \"{{field_name}}\" of the task {{obj_name}}", + "ISSUE_UPDATED_WITH_NEW_VALUE": "{{username}} has updated the attribute \"{{field_name}}\" of the issue {{obj_name}} to {{new_value}}", + "TASK_UPDATED": "{{username}} has updated the attribute \"{{field_name}}\" of the task {{obj_name}} to {{new_value}}", + "TASK_UPDATED_WITH_NEW_VALUE": "{{username}} has updated the attribute \"{{field_name}}\" of the task {{obj_name}} to {{new_value}}", "TASK_UPDATED_WITH_US": "{{username}} has updated the attribute \"{{field_name}}\" of the task {{obj_name}} which belongs to the US {{us_name}}", + "TASK_UPDATED_WITH_US_NEW_VALUE": "{{username}} has updated the attribute \"{{field_name}}\" of the task {{obj_name}} which belongs to the US {{us_name}} to {{new_value}}", "WIKI_UPDATED": "{{username}} has updated the wiki page {{obj_name}}", "NEW_COMMENT_US": "{{username}} has commented in the US {{obj_name}}", "NEW_COMMENT_ISSUE": "{{username}} has commented in the issue {{obj_name}}", diff --git a/app/modules/user-timeline/user-timeline-item/user-timeline-item-title.service.coffee b/app/modules/user-timeline/user-timeline-item/user-timeline-item-title.service.coffee index f315fe7c..bc34c4b6 100644 --- a/app/modules/user-timeline/user-timeline-item/user-timeline-item-title.service.coffee +++ b/app/modules/user-timeline/user-timeline-item/user-timeline-item-title.service.coffee @@ -38,6 +38,11 @@ class UserTimelineItemTitle return @._getLink(url, timeline.data.project.name) + else if param == 'new_value' + field_name = Object.keys(timeline.data.values_diff)[0] + + return timeline.data.values_diff[field_name][1] + else if param == 'sprint_name' url = 'project-taskboard:project=vm.activity.project.slug,sprint=vm.activity.sprint.slug' diff --git a/app/modules/user-timeline/user-timeline-item/user-timeline-item-title.service.spec.coffee b/app/modules/user-timeline/user-timeline-item/user-timeline-item-title.service.spec.coffee index 5bc7949d..36bc6f52 100644 --- a/app/modules/user-timeline/user-timeline-item/user-timeline-item-title.service.spec.coffee +++ b/app/modules/user-timeline/user-timeline-item/user-timeline-item-title.service.spec.coffee @@ -97,6 +97,30 @@ describe "tgUserTimelineItemTitle", -> expect(title).to.be.equal("title_ok") + it "title with new value", () -> + timeline = { + data: { + values_diff: { + status: ['old', 'new'] + } + } + } + + event = {} + + type = { + key: 'NEW_VALUE', + translate_params: ['new_value'] + } + + mockTranslate.instant + .withArgs('NEW_VALUE', {new_value: 'new'}) + .returns('new_value_ok') + + title = mySvc.getTitle(timeline, event, type) + + expect(title).to.be.equal("new_value_ok") + it "title with project name", () -> timeline = { data: { @@ -277,3 +301,37 @@ describe "tgUserTimelineItemTitle", -> title = mySvc.getTitle(timeline, event, type) expect(title).to.be.equal("title_ok") + + it "task title with us_name", () -> + timeline = { + data: { + task: { + name: 'task_name', + userstory: { + ref: 2 + subject: 'subject' + } + } + } + } + + event = { + obj: 'task', + } + + type = { + key: 'TITLE_OBJ', + translate_params: ['us_name'] + } + + objparam = sinon.match ((value) -> + return value.us_name == '#2 subject' + ), "objparam" + + mockTranslate.instant + .withArgs('TITLE_OBJ', objparam) + .returns('title_ok') + + title = mySvc.getTitle(timeline, event, type) + + expect(title).to.be.equal("title_ok") diff --git a/app/modules/user-timeline/user-timeline-item/user-timeline-item-type.service.coffee b/app/modules/user-timeline/user-timeline-item/user-timeline-item-type.service.coffee index 1b298aec..20d866a9 100644 --- a/app/modules/user-timeline/user-timeline-item/user-timeline-item-type.service.coffee +++ b/app/modules/user-timeline/user-timeline-item/user-timeline-item-type.service.coffee @@ -140,25 +140,69 @@ timelineType = (timeline, event) -> }, { # UsUpdated check: (timeline, event) -> - return event.obj == 'userstory' && event.type == 'change' + return event.obj == 'userstory' && + event.type == 'change' && + !timeline.data.values_diff.description_diff + key: 'TIMELINE.US_UPDATED_WITH_NEW_VALUE', + translate_params: ['username', 'field_name', 'obj_name', 'new_value'] + }, + { # UsUpdated description + check: (timeline, event) -> + return event.obj == 'userstory' && + event.type == 'change' && + timeline.data.values_diff.description_diff key: 'TIMELINE.US_UPDATED', translate_params: ['username', 'field_name', 'obj_name'] }, { # IssueUpdated check: (timeline, event) -> - return event.obj == 'issue' && event.type == 'change' + return event.obj == 'issue' && + event.type == 'change' && + !timeline.data.values_diff.description_diff + key: 'TIMELINE.ISSUE_UPDATED_WITH_NEW_VALUE', + translate_params: ['username', 'field_name', 'obj_name', 'new_value'] + }, + { # IssueUpdated description + check: (timeline, event) -> + return event.obj == 'issue' && + event.type == 'change' && + timeline.data.values_diff.description_diff key: 'TIMELINE.ISSUE_UPDATED', translate_params: ['username', 'field_name', 'obj_name'] }, { # TaskUpdated check: (timeline, event) -> - return event.obj == 'task' && event.type == 'change' && !timeline.data.task.userstory + return event.obj == 'task' && + event.type == 'change' && + !timeline.data.task.userstory && + !timeline.data.values_diff.description_diff + key: 'TIMELINE.TASK_UPDATED_WITH_NEW_VALUE', + translate_params: ['username', 'field_name', 'obj_name', 'new_value'] + }, + { # TaskUpdated description + check: (timeline, event) -> + return event.obj == 'task' && + event.type == 'change' && + !timeline.data.task.userstory && + timeline.data.values_diff.description_diff key: 'TIMELINE.TASK_UPDATED', translate_params: ['username', 'field_name', 'obj_name'] }, { # TaskUpdated with US check: (timeline, event) -> - return event.obj == 'task' && event.type == 'change' && timeline.data.task.userstory + return event.obj == 'task' && + event.type == 'change' && + timeline.data.task.userstory && + !timeline.data.values_diff.description_diff + key: 'TIMELINE.TASK_UPDATED_WITH_US_NEW_VALUE', + translate_params: ['username', 'field_name', 'obj_name', 'us_name', 'new_value'] + }, + { # TaskUpdated with US description + check: (timeline, event) -> + return event.obj == 'task' && + event.type == 'change' && + timeline.data.task.userstory && + timeline.data.values_diff.description_diff key: 'TIMELINE.TASK_UPDATED_WITH_US', translate_params: ['username', 'field_name', 'obj_name', 'us_name'] },