This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adding
ApiViewModel
class support
- Loading branch information
Showing
4 changed files
with
48 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { ApiViewModel } from '@api-components/api-view-model-transformer'; | ||
/** | ||
@license | ||
Copyright 2018 The Advanced REST client authors <[email protected]> | ||
|
@@ -266,31 +267,25 @@ export const ApiFormMixin = (base) => class extends base { | |
* `model`. | ||
* | ||
* @param {String} binding Value if the `binding` property. | ||
* @param {Object} opts Additional options: | ||
* - inputLabel {String} - Forces a label of the input | ||
* @param {Object=} opts Default options for the ModelItem. See `ApiViewModel` | ||
* for the details. | ||
*/ | ||
addCustom(binding, opts) { | ||
if (!opts) { | ||
opts = {}; | ||
} | ||
const e = new CustomEvent('api-property-model-build', { | ||
bubbles: true, | ||
composed: true, | ||
cancelable: true, | ||
detail: { | ||
name: opts.name || '', | ||
value: opts.value || '', | ||
binding: binding, | ||
schema: { | ||
enabled: true, | ||
isCustom: true, | ||
inputLabel: opts.inputLabel || undefined | ||
} | ||
addCustom(binding, opts={}) { | ||
const { name='', value='', inputLabel } = opts; | ||
const defaults = { | ||
name, | ||
value, | ||
binding, | ||
schema: { | ||
enabled: true, | ||
isCustom: true, | ||
inputLabel, | ||
} | ||
}); | ||
this.dispatchEvent(e); | ||
}; | ||
const worker = new ApiViewModel(); | ||
const item = worker.buildProperty(defaults); | ||
const model = this.model || []; | ||
this.model = [...model, e.detail]; | ||
this.model = [...model, item]; | ||
this.optionalOpened = true; | ||
} | ||
/** | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
"email": "[email protected]" | ||
}, | ||
"dependencies": { | ||
"@api-components/api-view-model-transformer": "^4.1.0", | ||
"lit-element": "^2.3.1" | ||
}, | ||
"devDependencies": { | ||
|
This file contains 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