Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update dependencies #392

Merged
merged 1 commit into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ update_configs:
- match:
dependency_type: "development"
update_type: "semver:minor"
ignored_updates:
- match:
# Can not be updated to the latest version because it requires ember 3.11+
# but this addon supports the last 2 LTS vesions i.e. 3.8 & 3.12
dependency_name: "ember-power-select"
version_requirement: ">=3"
commit_message:
prefix: "fix"
prefix_development: "chore"
include_scope: true
anehx marked this conversation as resolved.
Show resolved Hide resolved
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

root = true


[*]
end_of_line = lf
charset = utf-8
Expand Down
31 changes: 13 additions & 18 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
"use strict";

module.exports = {
root: true,
parser: "babel-eslint",
parserOptions: {
ecmaVersion: 2018,
sourceType: "module",
ecmaFeatures: {
legacyDecorators: true
}
legacyDecorators: true,
},
},
plugins: ["ember", "prettier"],
extends: [
"eslint:recommended",
"plugin:ember/recommended",
"plugin:prettier/recommended"
"plugin:prettier/recommended",
],
env: {
browser: true
browser: true,
},
rules: {
"ember/no-jquery": "error"
"ember/no-jquery": "error",
},
overrides: [
// node files
Expand All @@ -31,30 +33,23 @@ module.exports = {
"testem.js",
"blueprints/*/index.js",
"config/**/*.js",
"tests/dummy/config/**/*.js"
"tests/dummy/config/**/*.js",
],
excludedFiles: [
"addon/**",
"addon-test-support/**",
"app/**",
"tests/dummy/app/**"
"tests/dummy/app/**",
],
parserOptions: {
sourceType: "script",
ecmaVersion: 2015
},
env: {
browser: false,
node: true
node: true,
},
plugins: ["node"],
rules: Object.assign(
{},
require("eslint-plugin-node").configs.recommended.rules,
{
// add your custom rules and overrides for node files here
}
)
}
]
extends: ["plugin:node/recommended"],
},
],
};
4 changes: 2 additions & 2 deletions .template-lintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = {
extends: "recommended",
rules: {
"simple-unless": false,
"no-inline-styles": false
}
"no-inline-styles": false,
},
};
58 changes: 37 additions & 21 deletions addon/-private/themed-component.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
import { get, computed, getWithDefault } from "@ember/object";
import { get, computed } from "@ember/object";
import { getOwner } from "@ember/application";

export default component => {
return computed(function() {
const parts = component.split("/");
const [, ...componentNameParts] = parts;
export default (component) => {
return computed({
get() {
const parts = component.split("/");
const [, ...componentNameParts] = parts;

const config = getWithDefault(
getOwner(this).resolveRegistration("config:environment"),
"ember-validated-form",
{}
);
if (this.get(`overrideComponents.${componentNameParts}`)) {
return this.get(`overrideComponents.${componentNameParts}`);
}

const theme = get(config, "theme");
const defaultComponent = get(
config,
`defaults.${componentNameParts.join("/")}`
);
const config =
getOwner(this).resolveRegistration("config:environment")[
"ember-validated-form"
] !== undefined
? getOwner(this).resolveRegistration("config:environment")[
"ember-validated-form"
]
: {};

const name = parts.pop();
const basePath = parts.join("/");
const theme = config.theme;
const defaultComponent = get(
config,
`defaults.${componentNameParts.join("/")}`
);

return (
defaultComponent ||
(theme ? `${basePath}/-themes/${theme}/${name}` : `${basePath}/${name}`)
);
const name = parts.pop();
const basePath = parts.join("/");

return (
defaultComponent ||
(theme ? `${basePath}/-themes/${theme}/${name}` : `${basePath}/${name}`)
);
},
set(key, value) {
if (!this.get(`overrideComponents`)) {
this.set(`overrideComponents`, {});
}
this.set(`overrideComponents.${key}`, value);
return value;
},
});
};
2 changes: 1 addition & 1 deletion addon/components/validated-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export default Component.extend({
layout,
type: "button",
tagName: "",
buttonComponent: themedComponent("validated-button/button")
buttonComponent: themedComponent("validated-button/button"),
});
6 changes: 3 additions & 3 deletions addon/components/validated-button/-themes/bootstrap/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default Component.extend({
classNames: ["btn"],
classNameBindings: ["style"],

style: computed("type", function() {
return this.get("type") === "submit" ? "btn-primary" : "btn-default";
})
style: computed("type", function () {
return this.type === "submit" ? "btn-primary" : "btn-default";
}),
});
8 changes: 3 additions & 5 deletions addon/components/validated-button/-themes/uikit/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ export default Component.extend({
classNames: ["uk-button"],
classNameBindings: ["style"],

style: computed("type", function() {
return this.get("type") === "submit"
? "uk-button-primary"
: "uk-button-default";
})
style: computed("type", function () {
return this.type === "submit" ? "uk-button-primary" : "uk-button-default";
}),
});
2 changes: 1 addition & 1 deletion addon/components/validated-button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import layout from "../../templates/components/validated-button/button";
export default Component.extend({
layout,
tagName: "button",
attributeBindings: ["disabled", "type", "action:onclick"]
attributeBindings: ["disabled", "type", "action:onclick"],
});
10 changes: 5 additions & 5 deletions addon/components/validated-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export default Component.extend({

init() {
this._super(...arguments);
if (this.get("model") && this.get("model").validate) {
this.get("model").validate();
if (this.model && this.model.validate) {
this.model.validate();
}
},

submit() {
this.set("submitted", true);
const model = this.get("model");
const model = this.model;

if (!model || !model.validate) {
this.runCallback(PROP_ON_SUBMIT);
Expand All @@ -55,7 +55,7 @@ export default Component.extend({
if (typeof callback !== "function") {
return;
}
const model = this.get("model");
const model = this.model;

this.set("loading", true);
resolve(callback(model)).finally(() => {
Expand All @@ -65,5 +65,5 @@ export default Component.extend({
}
this.set("loading", false);
});
}
},
});
42 changes: 19 additions & 23 deletions addon/components/validated-input.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { computed, defineProperty } from "@ember/object";
import Component from "@ember/component";
import layout from "../templates/components/validated-input";
import v4 from "uuid/v4";
import { v4 } from "uuid";
import themedComponent from "../-private/themed-component";

/**
Expand Down Expand Up @@ -31,29 +31,28 @@ export default Component.extend({
defineProperty(
this,
"_val",
computed("value", `model.${this.get("name")}`, "name", function() {
return this.get("value") || this.get(`model.${this.get("name")}`);
computed("value", `model.${this.name}`, "name", function () {
return this.value || this.get(`model.${this.name}`);
})
);
},

inputId: computed(function() {
inputId: computed(function () {
return v4();
}),

errors: computed("model.error", function() {
return this.getWithDefault(
`model.error.${this.get("name")}.validation`,
[]
);
errors: computed("model.error", "name", function () {
return this.get(`model.error.${this.name}.validation`) === undefined
? []
: this.get(`model.error.${this.name}.validation`);
}),

isValid: computed("showValidity", "errors.[]", function() {
return this.get("showValidity") && !this.get("errors.length");
isValid: computed("showValidity", "errors.[]", function () {
return this.showValidity && !this.errors.length;
}),

isInvalid: computed("showValidity", "errors.[]", function() {
return this.get("showValidity") && !!this.get("errors.length");
isInvalid: computed("showValidity", "errors.[]", function () {
return this.showValidity && !!this.errors.length;
}),

renderComponent: themedComponent("validated-input/render"),
Expand All @@ -65,11 +64,8 @@ export default Component.extend({
"validateBeforeSubmit",
"dirty",
"submitted",
function() {
return (
this.get("submitted") ||
(this.get("validateBeforeSubmit") && this.get("dirty"))
);
function () {
return this.submitted || (this.validateBeforeSubmit && this.dirty);
}
),

Expand All @@ -79,11 +75,11 @@ export default Component.extend({
},

update(value) {
if (this.get("on-update")) {
this.get("on-update")(value, this.get("model"));
if (this["on-update"]) {
this["on-update"](value, this.model);
} else {
this.set(`model.${this.get("name")}`, value);
this.set(`model.${this.name}`, value);
}
}
}
},
},
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from "../../error";

export default Component.extend({
classNames: ["invalid-feedback"]
classNames: ["invalid-feedback"],
});
2 changes: 1 addition & 1 deletion addon/components/validated-input/-themes/bootstrap/hint.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from "../../hint";

export default Component.extend({
classNames: ["form-text", "text-muted"]
classNames: ["form-text", "text-muted"],
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from "../../render";

export default Component.extend({
classNames: ["form-group"]
classNames: ["form-group"],
});
2 changes: 1 addition & 1 deletion addon/components/validated-input/-themes/uikit/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import Component from "../../error";

export default Component.extend({
tagName: "small",
classNames: ["uk-text-danger"]
classNames: ["uk-text-danger"],
});
2 changes: 1 addition & 1 deletion addon/components/validated-input/-themes/uikit/hint.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from "../../hint";

export default Component.extend({
classNames: ["uk-text-muted"]
classNames: ["uk-text-muted"],
});
2 changes: 1 addition & 1 deletion addon/components/validated-input/-themes/uikit/label.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from "../../label";

export default Component.extend({
classNames: ["uk-form-label"]
classNames: ["uk-form-label"],
});
2 changes: 1 addition & 1 deletion addon/components/validated-input/-themes/uikit/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import layout from "../../../../templates/components/validated-input/-themes/uik

export default Component.extend({
layout,
classNames: ["uk-margin"]
classNames: ["uk-margin"],
});
2 changes: 1 addition & 1 deletion addon/components/validated-input/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import layout from "../../templates/components/validated-input/error";

export default Component.extend({
layout,
tagName: "span"
tagName: "span",
});
2 changes: 1 addition & 1 deletion addon/components/validated-input/hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import layout from "../../templates/components/validated-input/hint";

export default Component.extend({
layout,
tagName: "small"
tagName: "small",
});
2 changes: 1 addition & 1 deletion addon/components/validated-input/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import layout from "../../templates/components/validated-input/label";
export default Component.extend({
layout,
tagName: "label",
attributeBindings: ["inputId:for"]
attributeBindings: ["inputId:for"],
});
2 changes: 1 addition & 1 deletion addon/components/validated-input/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export default Component.extend({
radioGroupComponent: themedComponent("validated-input/types/radio-group"),
checkboxComponent: themedComponent("validated-input/types/checkbox"),
textareaComponent: themedComponent("validated-input/types/textarea"),
inputComponent: themedComponent("validated-input/types/input")
inputComponent: themedComponent("validated-input/types/input"),
});
Loading