Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surface missingCommissionedLengthReason field #476

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common-lib/src/main/scala/models/Stub.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ case class ExternalData(
hasMainMedia: Option[Boolean] = None,
commentable: Option[Boolean] = None,
commissionedLength: Option[Int] = None,
missingCommissionedLengthReason: Option[String] = None,
actualPublicationId: Option[Long] = None,
actualBookId: Option[Long] = None,
actualBookSectionId: Option[Long] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
wf-editable-input-type="number"
ng-model="contentItem.commissionedLength"
wf-editable-on-update="updateCommissionedLength(newValue)"
wf-editable-maxlength="5">{{contentItem.commissionedLength || "Add" }}
wf-editable-maxlength="5">{{contentItem.commissionedLength || formatReason(contentItem.missingCommissionedLengthReason) || "Add" }}
</wf-editable>
</li>
<li class="drawer__item">
Expand Down
29 changes: 20 additions & 9 deletions public/components/content-list-drawer/content-list-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,20 +332,31 @@ export function wfContentListDrawer($rootScope, config, $timeout, $window, conte
};

$scope.updateCommissionedLength = function (newValue) {
// Don't allow commissioned length to be unset
if(newValue === "") return;
Comment on lines +335 to +336
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy for others to disagree with this choice. But there doesn't seem to be much benefit in allowing people to remove a commissioned length from a piece that has one set.

Theoretically it would allow users to correct a mistake, but in practice since we expect all (or almost all) pieces to have a commissioned length, it seems more likely that someone might mis-use this feature, i.e. by setting an arbitrary commissioned length on the Workflow form and then removing it to get round the mandate.

if ($scope.contentItem.missingCommissionedLengthReason !== null && $scope.contentItem.missingCommissionedLengthReason !== undefined) {
updateField("missingCommissionedLengthReason", null);
wfComposerService.deleteField(
$scope.contentItem.composerId,
"missingCommissionedLengthReason"
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unset the missingCommissionedLengthReason when a commissioned length is set.

updateField("commissionedLength", newValue);
if (newValue === "") {
return wfComposerService.deleteField(
wfComposerService.updateField(
$scope.contentItem.composerId,
"commissionedLength"
);
}
return wfComposerService.updateField(
$scope.contentItem.composerId,
"commissionedLength",
newValue
"commissionedLength",
newValue
);
};

$scope.formatReason = (missingCommissionedLengthReason) => {
const reasons = {
"BreakingNews": "Breaking News",
}

return reasons[missingCommissionedLengthReason] || missingCommissionedLengthReason;
}

/**
* Revert deadline to previous state
*/
Expand Down
9 changes: 9 additions & 0 deletions public/components/content-list-item/content-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ function wfContentItemParser(config, wfFormatDateTime, statusLabels, sections) {
this.wordCount = item.wordCount;
this.printWordCount = item.printWordCount;
this.commissionedLength = item.commissionedLength;
this.missingCommissionedLengthReason = item.missingCommissionedLengthReason;

this.headline = item.headline;
this.standfirst = stripHtml(item.standfirst);
Expand Down Expand Up @@ -380,6 +381,14 @@ function wfCommissionedLengthCtrl ($scope) {
$scope.lengthStatus = "over";
}
});

$scope.formatReason = (missingCommissionedLengthReason) => {
const reasons = {
"BreakingNews": "Breaking News",
}

return reasons[missingCommissionedLengthReason] || missingCommissionedLengthReason;
}
}

export { wfContentListItem, wfContentItemParser, wfContentItemUpdateActionDirective, wfGetPriorityStringFilter, wfCommissionedLengthCtrl };
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
ng-attr-title="{{'Commissioned word count (' + lengthStatus + ' in comparison to web words)'}}">
<span ng-class="'content-list-item__field--commissionedLength-status-'+ lengthStatus"
ng-show="contentItem.contentType == 'article'">
{{ contentItem.commissionedLength }}
{{ contentItem.commissionedLength || formatReason(contentItem.missingCommissionedLengthReason) }}
</span>
</td>
21 changes: 11 additions & 10 deletions public/lib/column-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@ const columnDefaults = [{
isNew: true,
isSortable: true,
sortField: ['statusInPrint']
},{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-ordered so the commissionedLength can be next to the webWordCount (and so more easily comparable). But keeping webWordCount and printWordCount next to each other.

This is the inverse order of the Ophan screen (wordCount / commissionedLength), but hard to balance all the needs.

name: 'commissionedLength',
prettyName: 'Commissioned Length',
labelHTML: 'Commissioned Length',
colspan: 1,
title: '',
templateUrl: templateRoot + 'commissionedLength.html',
template: commissionedLengthTemplate,
active: true,
isSortable: true,
sortField: ['missingCommissionedLengthReason', 'commissionedLength']
Copy link
Contributor Author

@Fweddi Fweddi Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you now order the Commissioned Length field by ascending, you should see missingCommissionedLengthReason first. And then very low Commissioned Length values. So will be easier to see mis-use of Commissioned Length.

Would be nice if we could order by descending to see very high Commissioned Length values, but this just shows empty values as highest. Perhaps some refactoring of the sort would help? (Should blank values be included or not in sort is the bigger question).

},{
name: 'wordcount',
prettyName: 'Web wordcount',
Expand Down Expand Up @@ -347,16 +358,6 @@ const columnDefaults = [{
isSortable: true,
defaultSortOrder: ['asc', 'desc', 'asc'],
sortField: ['printLocationBookSection', 'printLocationPublicationDate', 'printLocationPageNumber']
},{
name: 'commissionedLength',
prettyName: 'Commissioned Length',
labelHTML: 'Commission',
colspan: 1,
title: '',
templateUrl: templateRoot + 'commissionedLength.html',
template: commissionedLengthTemplate,
active: true,
isSortable: true
},{
name: 'links',
prettyName: 'Open in...',
Expand Down
3 changes: 2 additions & 1 deletion public/lib/composer-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ function wfComposerService($http, $q, config, $log, wfHttpSessionService, wfTele
revision: (d) => deepSearch(d, ['contentChangeDetails', 'data', 'revision']),
lastModified: (d) => new Date(deepSearch(d, ['contentChangeDetails', 'data', 'lastModified', 'date']) || undefined),
lastModifiedBy: (d) => deepSearch(d, ['contentChangeDetails', 'data', 'lastModified', 'user', 'firstName']) + ' ' + deepSearch(d, ['contentChangeDetails', 'data', 'lastModified', 'user', 'lastName']),
commissionedLength: (d) => deepSearch(d, ['preview', 'data', 'fields', 'commissionedLength', 'data']) || undefined
commissionedLength: (d) => deepSearch(d, ['preview', 'data', 'fields', 'commissionedLength', 'data']) || undefined,
missingCommissionedLengthReason: (d) => deepSearch(d, ['preview', 'data', 'fields', 'missingCommissionedLengthReason', 'data']) || undefined
};


Expand Down
Loading