GUACAMOLE-742: Provide "disabled" attribute for forms and fields.

This commit is contained in:
Michael Jumper
2019-04-27 16:52:37 -07:00
parent fbcb04e670
commit 59fdc80e9f
14 changed files with 36 additions and 9 deletions

View File

@@ -64,7 +64,15 @@ angular.module('form').directive('guacForm', [function form() {
*
* @type Boolean
*/
modelOnly : '='
modelOnly : '=',
/**
* Whether the contents of the form should be rendered as disabled.
* By default, form fields are enabled.
*
* @type Boolean
*/
disabled : '='
},
templateUrl: 'app/form/templates/form.html',

View File

@@ -53,7 +53,15 @@ angular.module('form').directive('guacFormField', [function formField() {
*
* @type String
*/
model : '='
model : '=',
/**
* Whether this field should be rendered as disabled. By default,
* form fields are enabled.
*
* @type Boolean
*/
disabled : '='
},
templateUrl: 'app/form/templates/formField.html',

View File

@@ -213,6 +213,10 @@ angular.module('form').provider('formService', function formServiceProvider() {
* model:
* The current String value of the field, if any.
*
* disabled:
* A boolean value which is true if the field should be disabled.
* If false or undefined, the field should be enabled.
*
* @param {Element} fieldContainer
* The DOM Element whose contents should be replaced with the
* compiled field template.

View File

@@ -1 +1 @@
<input type="checkbox" ng-model="typedValue" autocorrect="off" autocapitalize="off"/>
<input type="checkbox" ng-disabled="disabled" ng-model="typedValue" autocorrect="off" autocapitalize="off"/>

View File

@@ -1,5 +1,6 @@
<div class="date-field">
<input type="date"
ng-disabled="disabled"
ng-model="typedValue"
ng-model-options="modelOptions"
guac-lenient-date

View File

@@ -1,5 +1,6 @@
<div class="email-field">
<input type="email"
ng-disabled="disabled"
ng-model="model"
ng-hide="readOnly"
autocorrect="off"

View File

@@ -9,6 +9,7 @@
<div class="fields">
<guac-form-field ng-repeat="field in form.fields" namespace="namespace"
ng-if="isVisible(field)"
disabled="disabled"
field="field" model="values[field.name]"></guac-form-field>
</div>

View File

@@ -1 +1 @@
<input type="number" ng-model="typedValue" autocorrect="off" autocapitalize="off"/>
<input type="number" ng-disabled="disabled" ng-model="typedValue" autocorrect="off" autocapitalize="off"/>

View File

@@ -1,4 +1,4 @@
<div class="password-field">
<input type="{{passwordInputType}}" ng-model="model" ng-trim="false" autocorrect="off" autocapitalize="off"/>
<input type="{{passwordInputType}}" ng-disabled="disabled" ng-model="model" ng-trim="false" autocorrect="off" autocapitalize="off"/>
<div class="icon toggle-password" ng-click="togglePassword()" title="{{getTogglePasswordHelpText() | translate}}"></div>
</div>

View File

@@ -1 +1,2 @@
<select ng-model="model" ng-options="option as getFieldOption(option) | translate for option in field.options | orderBy: value"></select>
<select ng-model="model" ng-disabled="disabled"
ng-options="option as getFieldOption(option) | translate for option in field.options | orderBy: value"></select>

View File

@@ -1 +1 @@
<textarea ng-model="model" autocorrect="off" autocapitalize="off"></textarea>
<textarea ng-model="model" autocorrect="off" autocapitalize="off" ng-disabled="disabled"></textarea>

View File

@@ -1,5 +1,6 @@
<div class="text-field">
<input type="text" ng-model="model" autocorrect="off" autocapitalize="off" ng-attr-list="{{ dataListId }}"/>
<input type="text" ng-model="model" autocorrect="off" autocapitalize="off"
ng-disabled="disabled" ng-attr-list="{{ dataListId }}"/>
<datalist ng-if="dataListId" id="{{ dataListId }}">
<option ng-repeat="option in field.options | orderBy: option"
value="{{ option }}">{{ getFieldOption(option) | translate }}</option>

View File

@@ -1,5 +1,6 @@
<div class="time-field">
<input type="time"
ng-disabled="disabled"
ng-model="typedValue"
ng-model-options="modelOptions"
guac-lenient-time

View File

@@ -2,12 +2,13 @@
<!-- Available time zone regions -->
<select class="time-zone-region"
ng-disabled="disabled"
ng-model="region"
ng-options="name for name in regions | orderBy: name"></select>
<!-- Time zones within selected region -->
<select class="time-zone"
ng-disabled="!region"
ng-disabled="disabled || !region"
ng-model="model"
ng-options="timeZone.value as timeZone.key for timeZone in timeZones[region] | toArray | orderBy: key"></select>