Apply same mechanism to checkbox form

This commit is contained in:
RyuAhyoung 2017-03-19 10:29:10 +09:00
parent 266f0c81d6
commit 5730796b56
3 changed files with 26 additions and 4 deletions

View file

@ -57,8 +57,10 @@ Also you can separate option's display name and value, using `${formName=default
<img src="../assets/themes/zeppelin/img/screenshots/form_select_displayname.png" />
The paragraph will be automatically run after you change your selection by default.
But in case you have multiple select forms in one paragraph, you might want to run the paragraph after changing all the selections.
You can control this by unchecking the below **Run on selection change** option in the setting menu. Even if you uncheck this option, still you can run it by pressing `Enter`.
But in case you have multiple types dynamic form in one paragraph, you might want to run the paragraph after changing all the selections.
You can control this by unchecking the below **Run on selection change** option in the setting menu.
Even if you uncheck this option, still you can run it by pressing `Enter`.
<img src="../assets/themes/zeppelin/img/screenshots/selectForm-checkbox.png" />
@ -72,6 +74,14 @@ Besides, you can specify the delimiter using `${checkbox(delimiter):formName=...
<img src="../assets/themes/zeppelin/img/screenshots/form_checkbox_delimiter.png">
Like [select form](#select-form), the paragraph will be automatically run after you change your selection by default.
But in case you have multiple types dynamic form in one paragraph, you might want to run the paragraph after changing all the selections.
You can control this by unchecking the below **Run on selection change** option in the setting menu.
Even if you uncheck this option, still you can run it by pressing `Enter`.
<img src="../assets/themes/zeppelin/img/screenshots/selectForm-checkbox.png" />
## Creates Programmatically
Some language backend uses programmatic way to create form. For example [ZeppelinContext](../interpreter/spark.html#zeppelincontext) provides form creation API

View file

@ -46,12 +46,24 @@ limitations under the License.
ng-options="option.value as (option.displayName||option.value) for option in paragraph.settings.forms[formulaire.name].options">
</select>
</div>
<div ng-if="paragraph.settings.forms[formulaire.name].type == 'checkbox'">
<div ng-if="paragraph.config.runOnSelectionChange == true &&
paragraph.settings.forms[formulaire.name].type == 'checkbox'">
<label ng-repeat="option in paragraph.settings.forms[formulaire.name].options"
class="checkbox-item input-sm">
<input type="checkbox"
ng-class="{'disable': paragraph.status == 'RUNNING' || paragraph.status == 'PENDING' }"
ng-checked="paragraph.settings.params[formulaire.name].indexOf(option.value) > -1"
ng-click="toggleCheckbox(formulaire, option, false); runParagraphFromButton(getEditorValue())"/> {{option.displayName||option.value}}
</label>
</div>
<div ng-if="paragraph.config.runOnSelectionChange == false &&
paragraph.settings.forms[formulaire.name].type == 'checkbox'">
<label ng-repeat="option in paragraph.settings.forms[formulaire.name].options"
class="checkbox-item input-sm">
<input type="checkbox"
ng-class="{'disable': paragraph.status == 'RUNNING' || paragraph.status == 'PENDING' }"
ng-checked="paragraph.settings.params[formulaire.name].indexOf(option.value) > -1"
ng-enter="runParagraphFromButton(getEditorValue())"
ng-click="toggleCheckbox(formulaire, option, false)"/> {{option.displayName||option.value}}
</label>
</div>

View file

@ -140,7 +140,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
for (var idx in forms) {
if (forms[idx]) {
if (forms[idx].options && forms[idx].type !== 'checkbox') {
if (forms[idx].options) {
if (config.runOnSelectionChange === undefined) {
config.runOnSelectionChange = true;
}