Skip to content

Commit 46d4567

Browse files
committed
feat: hide fields if external config selected
1 parent 40c7532 commit 46d4567

3 files changed

Lines changed: 36 additions & 22 deletions

File tree

lti_consumer/static/js/xblock_studio_view.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ function LtiConsumerXBlockInitStudio(runtime, element, data) {
5757
} else {
5858
$(element).find(".l1p1").addClass("hidden");
5959
$(element).find(".l1p3").removeClass("hidden");
60-
60+
if (configType !== "new") {
61+
$(element).find(".no-external-config").addClass("hidden");
62+
$(element).find(".external-config").removeClass("hidden");
63+
} else {
64+
$(element).find(".external-config").addClass("hidden");
65+
$(element).find(".no-external-config").removeClass("hidden");
66+
}
6167
}
6268

6369
if (configType === "new") {
@@ -69,8 +75,15 @@ function LtiConsumerXBlockInitStudio(runtime, element, data) {
6975
}
7076

7177
if (configType === "external") {
72-
// Conditionally show the LTI 1.3 launch URL field if external multiple launch URLs are enabled.
73-
toggleFieldVisibility("lti_1p3_launch_url", data.EXTERNAL_MULTIPLE_LAUNCH_URLS_ENABLED);
78+
if (data.EXTERNAL_MULTIPLE_LAUNCH_URLS_ENABLED) {
79+
// Conditionally show the LTI 1.3 launch URL field if external multiple launch URLs are enabled.
80+
toggleFieldVisibility("lti_1p3_launch_url", true);
81+
$(element).find(".field-group-lti-configuration-details.l1p3").addClass("hidden");
82+
} else {
83+
toggleFieldVisibility("lti_1p3_launch_url", false);
84+
// Also hides the field-group-lti-configuration-details as it is empty in this case
85+
$(element).find(".field-group-lti-configuration-details.l1p3").addClass("hidden");
86+
}
7487
}
7588
}
7689

@@ -158,18 +171,18 @@ function LtiConsumerXBlockInitStudio(runtime, element, data) {
158171
* @param {string} step - The step to deactivate.
159172
*/
160173
function deactivateCurrentStep() {
161-
$(element).find(`.step-header-${currentStep}`).removeClass("pgn__stepper-header-step-active");
162-
$(element).find(`.step-${currentStep}`).addClass("hidden");
163-
};
174+
$(element).find(`.step-header-${currentStep}`).removeClass("pgn__stepper-header-step-active");
175+
$(element).find(`.step-${currentStep}`).addClass("hidden");
176+
}
164177

165178
/**
166179
* Show the current step and activate the step header.
167180
*
168181
* @param {string} step - The step to activate.
169182
*/
170183
function activateCurrentStep() {
171-
$(element).find(`.step-header-${currentStep}`).addClass("pgn__stepper-header-step-active");
172-
$(element).find(`.step-${currentStep}`).removeClass("hidden");
184+
$(element).find(`.step-header-${currentStep}`).addClass("pgn__stepper-header-step-active");
185+
$(element).find(`.step-${currentStep}`).removeClass("hidden");
173186
}
174187

175188
/**
@@ -178,10 +191,10 @@ function LtiConsumerXBlockInitStudio(runtime, element, data) {
178191
* @param {string} step - The step to change to.
179192
*/
180193
function changeStep(step) {
181-
deactivateCurrentStep();
182-
currentStep = step;
183-
activateCurrentStep();
184-
handlePrevNextButtonVisibility();
194+
deactivateCurrentStep();
195+
currentStep = step;
196+
activateCurrentStep();
197+
handlePrevNextButtonVisibility();
185198
}
186199

187200
// Show or hide fields based on the selected options
@@ -209,7 +222,6 @@ function LtiConsumerXBlockInitStudio(runtime, element, data) {
209222
$(wrapper).addClass("is-set");
210223
});
211224

212-
213225
// Bind to onChange method of lti_version selector
214226
$(element)
215227
.find("[id^=lti_version_option-]")
@@ -359,7 +371,6 @@ function LtiConsumerXBlockInitStudio(runtime, element, data) {
359371
changeStep("review");
360372
});
361373

362-
363374
/**
364375
* Return whether the field is set or not.
365376
*

lti_consumer/templates/html/lti_studio_edit/_step_setup.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ <h6 class="field-group-heading">
120120
</h6>
121121
<ul class="list-input settings-list">
122122
<!------------ lti_1p3_launch_url -------------->
123-
<li class="field comp-setting-entry {% if fields.lti_1p3_launch_url.is_set %}is-set{% endif %}">
123+
<li
124+
class="field comp-setting-entry {% if fields.lti_1p3_launch_url.is_set %}is-set{% endif %}"
125+
data-field-name="lti_1p3_launch_url"
126+
>
124127
<label class="label setting-label">{{ fields.lti_1p3_launch_url.display_name }}</label>
125128
<span class="icon fa fa-question-circle" data-tooltip="{{ fields.lti_1p3_launch_url.help }}"></span>
126129
<input
@@ -133,7 +136,7 @@ <h6 class="field-group-heading">
133136
<!---------------------------------------------->
134137

135138
<!------------ lti_1p3_oidc_url -------------->
136-
<li class="field comp-setting-entry {% if fields.lti_1p3_oidc_url.is_set %}is-set{% endif %}">
139+
<li class="field comp-setting-entry {% if fields.lti_1p3_oidc_url.is_set %}is-set{% endif %} no-external-config">
137140
<label class="label setting-label">{{ fields.lti_1p3_oidc_url.display_name }}</label>
138141
<span class="icon fa fa-question-circle" data-tooltip="{{ fields.lti_1p3_oidc_url.help }}"></span>
139142
<input
@@ -145,7 +148,7 @@ <h6 class="field-group-heading">
145148
</li>
146149
<!-------------------------------------------->
147150
<!------------ lti_1p3_redirect_uris -------------->
148-
<li class="field comp-setting-entry {% if fields.lti_1p3_redirect_uris.is_set %}is-set{% endif %}">
151+
<li class="field comp-setting-entry {% if fields.lti_1p3_redirect_uris.is_set %}is-set{% endif %} no-external-config">
149152
<label class="label setting-label">{{ fields.lti_1p3_redirect_uris.display_name }}</label>
150153
<span class="icon fa fa-question-circle" data-tooltip="{{ fields.lti_1p3_redirect_uris.help }}"></span>
151154
<textarea

lti_consumer/templates/html/lti_studio_edit/_stepper_header.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
</li>
1313
</a>
1414
<li aria-hidden="true" class="pgn__stepper-header-line"></li>
15-
<a href="#" class="step-header-advantage-link">
16-
<li class="pgn__stepper-header-step step-header-advantage l1p3">
15+
<a href="#" class="step-header-advantage-link l1p3 no-external-config">
16+
<li class="pgn__stepper-header-step step-header-advantage">
1717
<div class="pgn__bubble">
1818
<span>2</span>
1919
</div>
@@ -22,12 +22,12 @@
2222
</div>
2323
</li>
2424
</a>
25-
<li aria-hidden="true" class="pgn__stepper-header-line l1p3"></li>
25+
<li aria-hidden="true" class="pgn__stepper-header-line l1p3 no-external-config"></li>
2626
<a href="#" class="step-header-review-link">
2727
<li class="pgn__stepper-header-step step-header-review">
2828
<div class="pgn__bubble">
29-
<span class="l1p1">2</span>
30-
<span class="l1p3">3</span>
29+
<span class="l1p1 external-config">2</span>
30+
<span class="l1p3 no-external-config">3</span>
3131
</div>
3232
<div class="pgn__stepper-header-step-title-description">
3333
<div class="pgn__stepper-header-step-title">{% trans "Review Options" %}</div>

0 commit comments

Comments
 (0)