Skip to content

Commit

Permalink
Merge pull request #33844 from dimagi/em/stripe-repeats-attribute
Browse files Browse the repository at this point in the history
Apply repeat striping with stripe-repeats appearance attribute
  • Loading branch information
nospame authored Dec 11, 2023
2 parents 15ae45f + d5fa19e commit 7679bdf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ hqDefine("cloudcare/js/form_entry/const", function () {
BUTTON_SELECT: 'button-select',
SHORT: 'short',
MEDIUM: 'medium',
STRIPE_REPEATS: 'stripe-repeats',

// Note it's important to differentiate these two
NO_PENDING_ANSWER: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ hqDefine("cloudcare/js/form_entry/form_ui", function () {
};

var styles = _.has(json, 'style') && json.style && json.style.raw ? json.style.raw.split(/\s+/) : [];
self.stripeRepeats = _.contains(styles, constants.STRIPE_REPEATS);
self.collapsible = _.contains(styles, constants.COLLAPSIBLE);
self.showChildren = ko.observable(!self.collapsible || _.contains(styles, constants.COLLAPSIBLE_OPEN));
self.toggleChildren = function () {
Expand Down
3 changes: 2 additions & 1 deletion corehq/apps/cloudcare/templates/form_entry/templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

<script type="text/html" id="sub-group-fullform-ko-template">
<div tabindex="-1" class ="gr" data-bind="
class: isRepetition ? 'repetition' : '',
css: {
'gr-no-children': $data.children().length === 0,
'gr-has-no-questions': _.all($data.children(), function(d) { return d.type() !== 'grouped-question-tile-row' }),
'gr-has-no-nested-questions': !$data.hasAnyNestedQuestions(),
'panel panel-default': collapsible,
'repetition': isRepetition,
'required-group': !showChildren() && childrenRequired(),
'stripe-repeats': stripeRepeats,
}">
<fieldset class="gr-header" data-bind="
css: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@
}
}

.stripe-repeats {
.gr {
&:nth-of-type(odd) {
background-color: @table-bg-accent;
}
&:nth-of-type(even) {
background-color: white;
}
&:hover {
background-color: @table-bg-hover;
}
}
}

.info {
overflow-x: auto;
}
Expand Down

0 comments on commit 7679bdf

Please sign in to comment.