-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add editable maxItems field in Config tool #1763
Conversation
build.sbt
Outdated
@@ -83,7 +83,7 @@ libraryDependencies ++= Seq( | |||
"com.gu" %% "content-api-client-aws" % "0.7.6", | |||
"com.gu" %% "content-api-client-default" % capiClientVersion, | |||
"com.gu" %% "editorial-permissions-client" % "3.0.0", | |||
"com.gu" %% "fapi-client-play30" % "15.0.0", | |||
"com.gu" %% "fapi-client-play30" % "16.0.0-PREVIEW.fpadd-groups-config-field.2025-02-21T1227.15f48131", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need to swap out for 16.0.0 once guardian/facia-scala-client#345 is released.
564bf14
to
9f359da
Compare
740e2ca
to
76f9439
Compare
e7750a2
to
c3c96ff
Compare
b7605a8
to
13fc4ef
Compare
6cb9177
to
f50a18c
Compare
@@ -65,7 +68,8 @@ function flattenModel (model) { | |||
return _.reduce(model, function (accumulator, value, key) { | |||
var x = flattenValue(value); | |||
|
|||
if (x) { | |||
// We want to drop falsy values, but not 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cf. #682
This pr also cleans all falsy values and empty arrays from the meta object to correspond with what is saved in the meta by v1 and avoid any obscure future bugs.
There are a couple of places in the tests where we are explicitly testing falsy values are filtered out, so this seemed the minimum change to allow us to support 0 as a value.
0 as a value is useful as it lets config editors know that a group (e.g. Very Big) has explicitly been set to 0 rather than it is unset and waiting to be filled in.
display: inline-block; | ||
} | ||
|
||
.capitalize-first-letter:first-letter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means we can write 'very big' as 'Very big' (and not 'Very Big' which text-transform: capitalize
would do if left to its own devices).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Stakeholder request)
It would be good to have future PRs to:
*At least, at this current moment... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
I've made a few non-blocking suggestions
@@ -65,7 +68,8 @@ function flattenModel (model) { | |||
return _.reduce(model, function (accumulator, value, key) { | |||
var x = flattenValue(value); | |||
|
|||
if (x) { | |||
// We want to drop falsy values, but not 0 | |||
if (x || x === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
classic. I'm a big fan of https://typescript-eslint.io/rules/strict-boolean-expressions/
@@ -8,7 +8,7 @@ export default function(initialValue) { | |||
}, | |||
write(newValue) { | |||
var parsedValue = parseFloat(newValue); | |||
actual(isNaN(parsedValue) ? newValue : parsedValue); | |||
actual(isNaN(parsedValue) ? newValue : Math.abs(parsedValue)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the Math.abs
required? This is slightly unexpected behaviour for something called "observable-numeric"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It prevents us from modelling negative numbers. This code is invoked in the few cases we expect numbers, and we have already checked at this stage that the variable definitely is a number. Happy to jettison it or move it elsewhere though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We plan to EOL this app so it is not really a problem for this API to be confusing, let's leave as is.
(with apologies to me or other future developer who gets bitten by this in 5 years time when we are still using this code)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can address this when we fix the suppressImages
being treated as an observableNumeric
.
<!-- ko if: meta.type() === "flexible/general"--> | ||
<div data-bind="foreach: meta.groupsConfig"> | ||
<label for="flexGenSplashStoryLimit"><span data-bind="text: name" class="capitalize-first-letter"></span> stories</label> | ||
<input id="flexGenSplashStoryLimit" type="number" data-bind="value: maxItems" attr: { max: 20, min: 0 } max="20" min="0"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
should be unique, and "SplashStory" in the id
is no longer accurate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actioned
When we do For |
Thank you for clarifying 2 as I'd expected us to want to keep the hard limit introduced in #1753. |
It is fine for the hard-limit to be controlled by configuration, rather than hardcoded. |
<label data-bind="attr: { for: name }"><span data-bind="text: name" class="capitalize-first-letter"></span> stories</label> | ||
<input type="number" data-bind="value: maxItems, attr: { id: name, max: 20, min: 0 }" max="20" min="0"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think id
s can have whitespace. Perhaps this will work (untested):
attr: { for: 'maxItems-' + $index }
8380b3d
to
1e2dad6
Compare
1e2dad6
to
3d0888b
Compare
What's changed?
Add an editable maxItems field per 'group' (e.g. splash, standard) in a given container.
This allows the new
flexible/general
container to have different card groups with variable card limits.Intended to replace the use of the
maxItemsToDisplay
field. Note this PR does not enforce any card limits in the Fronts Tool, this will be carried out in a future PR.Note you will need to 'reset' the container to see the
groupsConfig
defaults pull through. So if you are looking at aflexible/general
container in the config, you will need to change the container type to something else and then back toflexible/general
.