This repository was archived by the owner on Aug 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
feat(oui-inline-adder): add inline-adder component #304
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| # Inline adder | ||
|
|
||
| <component-status cx-design="complete" ux="rc"></component-status> | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Basic | ||
|
|
||
| ```html:preview | ||
| <oui-inline-adder> | ||
| <oui-inline-adder-row> | ||
| <oui-inline-adder-field> | ||
| <oui-field label="Field 1"> | ||
| <input type="text" class="oui-input" name="field1" ng-model="field1" required> | ||
| </oui-field> | ||
| </oui-inline-adder-field> | ||
| <oui-inline-adder-field ng-hide="$ctrl.togglerLoading"> | ||
| <oui-field label="Field 2"> | ||
| <input type="text" class="oui-input" name="field2" ng-model="field2" required> | ||
| </oui-field> | ||
| </oui-inline-adder-field> | ||
| </oui-inline-adder-row> | ||
| </oui-inline-adder> | ||
| ``` | ||
|
|
||
| ### Multiple rows | ||
|
|
||
| ```html:preview | ||
| <oui-inline-adder> | ||
| <oui-inline-adder-row> | ||
| <oui-inline-adder-field> | ||
| <oui-field label="Field 1"> | ||
| <input type="text" class="oui-input" name="field1" ng-model="field1" required> | ||
| </oui-field> | ||
| </oui-inline-adder-field> | ||
| <oui-inline-adder-field> | ||
| <oui-field label="Field 2"> | ||
| <input type="text" class="oui-input" name="field2" ng-model="field2"> | ||
| </oui-field> | ||
| </oui-inline-adder-field> | ||
| </oui-inline-adder-row> | ||
| <oui-inline-adder-row> | ||
| <oui-inline-adder-field> | ||
| <oui-field label="Field 3"> | ||
| <input type="text" class="oui-input" name="field3" ng-model="field3" required> | ||
| </oui-field> | ||
| </oui-inline-adder-field> | ||
| <oui-inline-adder-field> | ||
| <oui-field label="Field 4"> | ||
| <input type="text" class="oui-input" name="field4" ng-model="field4"> | ||
| </oui-field> | ||
| </oui-inline-adder-field> | ||
| </oui-inline-adder-row> | ||
| </oui-inline-adder> | ||
| ``` | ||
|
|
||
| ### Adaptive fields | ||
|
|
||
| **Note**: Fields with `adaptive` attribute will adapt their size to their content. | ||
|
|
||
| ```html:preview | ||
| <oui-inline-adder> | ||
| <oui-inline-adder-row> | ||
| <oui-inline-adder-field> | ||
| <oui-field label="Field 1"> | ||
| <input type="text" class="oui-input" name="field1" ng-model="field1" required> | ||
| </oui-field> | ||
| </oui-inline-adder-field> | ||
| <oui-inline-adder-field adaptive> | ||
| <oui-field label="Field 2" size="m"> | ||
| <label class="oui-select"> | ||
| <select name="field2" ng-model="field2" class="oui-select__input" required> | ||
| <option value="" disabled selected>Select the OS</option> | ||
| <option value="freebsd">FreeBSD</option> | ||
| <option value="linux">Linux</option> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you may know, Linux is not an operating system. You probably mean a GNU/Linux distributions right? :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll update the example. It comes from the past contribution. |
||
| <option value="osx">OSX</option> | ||
| <option value="windows">Windows</option> | ||
| </select> | ||
| <span class="oui-icon oui-icon-chevron-down" aria-hidden="true"></span> | ||
| </label> | ||
| </oui-field> | ||
| </oui-inline-adder-field> | ||
| <oui-inline-adder-field adaptive> | ||
| <oui-field label="Field 3"> | ||
| <oui-numeric name="field3" model="field3"></oui-numeric> | ||
| </oui-field> | ||
| </oui-inline-adder-field> | ||
| </oui-inline-adder-row> | ||
| </oui-inline-adder> | ||
| ``` | ||
|
|
||
| ### Events | ||
|
|
||
| #### `on-add` | ||
|
|
||
| **Note**: If you want to access the form inside `on-add` callback, you need to use the `form` variable as below. | ||
|
|
||
| ```html:preview | ||
| <oui-inline-adder on-add="$ctrl.onAdd(form)"> | ||
| <oui-inline-adder-row> | ||
| <oui-inline-adder-field> | ||
| <oui-field label="Field 1"> | ||
| <input type="text" class="oui-input" name="field1" ng-model="field1" required> | ||
| </oui-field> | ||
| </oui-inline-adder-field> | ||
| </oui-inline-adder-row> | ||
| </oui-inline-adder> | ||
| <div class="oui-doc-preview-only"> | ||
| <p>On Add</p> | ||
| <pre class="oui-doc-code oui-doc-code_json">{{$ctrl.addedForm | json}}</pre> | ||
| </div> | ||
| ``` | ||
|
|
||
| #### `on-remove` | ||
|
|
||
| **Note**: If you want to access the form inside `on-remove` callback, you need to use the `form` variable as below. | ||
|
|
||
| ```html:preview | ||
| <oui-inline-adder on-remove="$ctrl.onRemove(form)"> | ||
| <oui-inline-adder-row> | ||
| <oui-inline-adder-field> | ||
| <oui-field label="Field 1"> | ||
| <input type="text" class="oui-input" name="field1" ng-model="field1" required> | ||
| </oui-field> | ||
| </oui-inline-adder-field> | ||
| </oui-inline-adder-row> | ||
| </oui-inline-adder> | ||
| <div class="oui-doc-preview-only"> | ||
| <p>On Remove</p> | ||
| <pre class="oui-doc-code oui-doc-code_json">{{$ctrl.removedForm | json}}</pre> | ||
| </div> | ||
| ``` | ||
|
|
||
| #### `on-change` | ||
|
|
||
| **Note**: If you want to access the forms array inside `on-change` callback, you need to use the `forms` variable as below. | ||
|
|
||
| ```html:preview | ||
| <oui-inline-adder on-change="$ctrl.onChange(forms)"> | ||
| <oui-inline-adder-row> | ||
| <oui-inline-adder-field> | ||
| <oui-field label="Field 1"> | ||
| <input type="text" class="oui-input" name="field1" ng-model="field1" required> | ||
| </oui-field> | ||
| </oui-inline-adder-field> | ||
| </oui-inline-adder-row> | ||
| </oui-inline-adder> | ||
| <div class="oui-doc-preview-only"> | ||
| <p>On Change</p> | ||
| <pre class="oui-doc-code oui-doc-code_json">{{$ctrl.changedForms | json}}</pre> | ||
| </div> | ||
| ``` | ||
|
|
||
| ## API | ||
|
|
||
| ### oui-inline-adder | ||
|
|
||
| | Attribute | Type | Binding | One-time binding | Values | Default | Description | ||
| | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ||
| | `on-add` | function | & | no | n/a | n/a | handler triggered when a row is added | ||
| | `on-remove` | function | & | no | n/a | n/a | handler triggered when a row is removed | ||
| | `on-change` | function | & | no | n/a | n/a | handler triggered when rows have changed | ||
|
|
||
| ### oui-inline-adder-field | ||
|
|
||
| | Attribute | Type | Binding | One-time binding | Values | Default | Description | ||
| | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ||
| | `adaptive` | boolean | <? | yes | `true`, `false` | `false` | adaptive field flag | ||
8 changes: 8 additions & 0 deletions
8
packages/oui-inline-adder/src/field/inline-adder-field.component.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import controller from "./inline-adder-field.controller"; | ||
|
|
||
| export default { | ||
| bindings: { | ||
| adaptive: "<?" | ||
| }, | ||
| controller | ||
| }; |
25 changes: 25 additions & 0 deletions
25
packages/oui-inline-adder/src/field/inline-adder-field.controller.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { addBooleanParameter } from "@ovh-ui/common/component-utils"; | ||
|
|
||
| export default class { | ||
| constructor ($attrs, $element, $timeout) { | ||
| "ngInject"; | ||
|
|
||
| this.$attrs = $attrs; | ||
| this.$element = $element; | ||
| this.$timeout = $timeout; | ||
| } | ||
|
|
||
| $onInit () { | ||
| addBooleanParameter(this, "adaptive"); | ||
| } | ||
|
|
||
| $postLink () { | ||
| this.$timeout(() => { | ||
| this.$element.addClass("oui-inline-adder__field"); | ||
|
|
||
| if (this.adaptive) { | ||
| this.$element.addClass("oui-inline-adder__field_adaptive"); | ||
| } | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import InlineAdder from "./inline-adder.component"; | ||
| import InlineAdderField from "./field/inline-adder-field.component"; | ||
| import InlineAdderProvider from "./inline-adder.provider"; | ||
| import InlineAdderRow from "./row/inline-adder-row.component"; | ||
|
|
||
| export default angular | ||
| .module("oui.inline-adder", []) | ||
| .component("ouiInlineAdder", InlineAdder) | ||
| .component("ouiInlineAdderField", InlineAdderField) | ||
| .component("ouiInlineAdderRow", InlineAdderRow) | ||
| .provider("ouiInlineAdderConfiguration", InlineAdderProvider) | ||
| .name; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.