Skip to content

Commit dde1eb8

Browse files
authored
Merge pull request #16 from Gaurav0/rename_back
Add tests, extend functionality and composability
2 parents ca086ca + 07dc97a commit dde1eb8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1342
-391
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88

99
# dependencies
1010
/bower_components/
11+
/node_modules/
1112

1213
# misc
1314
/coverage/
15+
!.*
1416

1517
# ember-try
1618
/.node_modules.ember-try/

.eslintrc.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,38 @@ module.exports = {
1515
browser: true
1616
},
1717
rules: {
18-
}
18+
},
19+
overrides: [
20+
// node files
21+
{
22+
files: [
23+
'.eslintrc.js',
24+
'.template-lintrc.js',
25+
'ember-cli-build.js',
26+
'index.js',
27+
'testem.js',
28+
'blueprints/*/index.js',
29+
'config/**/*.js',
30+
'tests/dummy/config/**/*.js'
31+
],
32+
excludedFiles: [
33+
'addon/**',
34+
'addon-test-support/**',
35+
'app/**',
36+
'tests/dummy/app/**'
37+
],
38+
parserOptions: {
39+
sourceType: 'script',
40+
ecmaVersion: 2015
41+
},
42+
env: {
43+
browser: false,
44+
node: true
45+
},
46+
plugins: ['node'],
47+
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
48+
// add your custom rules and overrides for node files here
49+
})
50+
}
51+
]
1952
};

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/node_modules/
1010

1111
# misc
12+
/.env*
1213
/.sass-cache
1314
/connect.lock
1415
/coverage/

.npmignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
/.bowerrc
1010
/.editorconfig
1111
/.ember-cli
12+
/.env*
1213
/.eslintignore
1314
/.eslintrc.js
1415
/.gitignore
15-
/.watchmanconfig
16+
/.template-lintrc.js
1617
/.travis.yml
18+
/.watchmanconfig
1719
/bower.json
1820
/config/ember-try.js
21+
/CONTRIBUTING.md
1922
/ember-cli-build.js
2023
/testem.js
2124
/tests/

.travis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ env:
1919
# See https://git.io/vdao3 for details.
2020
- JOBS=1
2121

22+
branches:
23+
only:
24+
- master
25+
# npm version tags
26+
- /^v\d+\.\d+\.\d+/
27+
2228
jobs:
2329
fail_fast: true
2430
allow_failures:
@@ -44,7 +50,8 @@ jobs:
4450
# as well as latest stable release (bonus points to beta/canary)
4551
- stage: "Additional Tests"
4652
env: EMBER_TRY_SCENARIO=ember-lts-2.16
47-
- env: EMBER_TRY_SCENARIO=ember-lts-2.18
53+
env: EMBER_TRY_SCENARIO=ember-lts-2.18
54+
- env: EMBER_TRY_SCENARIO=ember-lts-3.4
4855
- env: EMBER_TRY_SCENARIO=ember-release
4956
- env: EMBER_TRY_SCENARIO=ember-beta
5057
- env: EMBER_TRY_SCENARIO=ember-canary

CONTRIBUTING.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# How To Contribute
2+
3+
## Installation
4+
5+
* `git clone https://github.com/btecu/ember-simple-tree`
6+
* `cd my-addon`
7+
* `npm install`
8+
9+
## Linting
10+
11+
* `npm run lint:hbs`
12+
* `npm run lint:js`
13+
* `npm run lint:js -- --fix`
14+
15+
## Running tests
16+
17+
* `ember test` – Runs the test suite on the current Ember version
18+
* `ember test --server` – Runs the test suite in "watch mode"
19+
* `ember try:each` – Runs the test suite against multiple Ember versions
20+
21+
## Running the dummy application
22+
23+
* `ember serve`
24+
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).
25+
26+
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2018
3+
Copyright (c) 2019
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

README.md

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# ember-simple-tree
22

3-
Simple tree component for Ember without any dependency.
3+
Lightweight, composable tree component for Ember without any dependency.
4+
5+
## Compatibility
6+
7+
* Ember.js v2.16 or above
8+
* Ember CLI v2.13 or above
9+
10+
If you are using 0.5.x and would like to upgrade to 0.6.0, please note there
11+
are BREAKING CHANGES. For details, see (Upgrading)[UPGRADING.md].
12+
413

514
## Installation
615

@@ -17,6 +26,19 @@ Basic example:
1726
{{x-tree model=tree}}
1827
```
1928

29+
Standard example:
30+
31+
```handlebars
32+
{{#x-tree
33+
model=tree
34+
checkable=true
35+
as |node|
36+
}}
37+
{{node.toggle}}
38+
{{node.checkbox}}
39+
{{node.model.name}}
40+
{{/x-tree}}
41+
```
2042

2143
### Available actions
2244

@@ -115,21 +137,53 @@ Accepts: `boolean`
115137
When enabled, checking a box will also check children's boxes as well. Also enables indeterminate state for checkboxes.
116138
Has no effect if `checkable` is not enabled.
117139

140+
#### expandedIcon
141+
142+
Default: `x-tree-expanded-icon`,
143+
144+
Accepts: `string` or `Component`
145+
146+
```handlebars
147+
{{x-tree model=tree expandedIcon=(component "my-expanded-icon-component")}}
148+
```
149+
or
150+
```handlebars
151+
{{x-tree model=tree expandedIcon="my-expanded-icon-component"}}
152+
```
153+
154+
Component to use for expanded icon
155+
156+
#### collapsedIcon
157+
158+
Default: `x-tree-collapsed-icon`,
159+
160+
Accepts: `string`
161+
162+
```handlebars
163+
{{x-tree model=tree collapsedIcon=(component "my-collapsed-icon-component")}}
164+
```
165+
or
166+
```handlebars
167+
{{x-tree model=tree collapsedIcon="my-collapsed-icon-component"}}
168+
```
169+
170+
Component to use for collapsed icon
171+
118172
### Blocks
119173

120174
You may optionally pass a block to the `x-tree` component to render each node area with custom HTML.
121-
The node area is the area directly to the right of each arrow (and possibly checkbox) in the tree.
122-
The Node yields back the model for each area so that you can use attributes dynamically.
123175

124176
```handlebars
125177
{{#x-tree
126178
chosenId=selectedNode
127179
checkable=isCheckable
128180
expandDepth=2
129181
onSelect=(action 'selectNode')
130-
model=model as |node|}}
131-
<i class="fa text-muted {{if node.isExpanded 'fa-folder-open' 'fa-folder'}}">&zwnj;</i>
132-
{{node.name}}
182+
model=model
183+
as |node|
184+
}}
185+
<i class="fa text-muted {{if node.isExpanded 'fa-folder-open' 'fa-folder'}}">&zwnj;</i>
186+
{{node.model.name}}
133187
{{/x-tree}}
134188
```
135189

UPGRADING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Upgrading
2+
3+
## from 0.5.x to 0.6.0
4+
5+
If you are using the block form of the {{x-tree}} component,
6+
the expand/collapse toggle and the checkbox are no longer
7+
included in the custom HTML. Furthermore, the value yielded
8+
is no longer the model for the node, but an object containing
9+
the model and the components that are included.
10+
11+
To upgrade, convert:
12+
13+
```
14+
{{#x-tree
15+
model=tree
16+
checkable=true
17+
as |node|
18+
}}
19+
{{node.name}}
20+
{{/x-tree}}
21+
```
22+
23+
to
24+
25+
```
26+
{{#x-tree
27+
model=tree
28+
checkable=true
29+
as |node|
30+
}}
31+
{{node.toggle}}
32+
{{node.checkbox}}
33+
{{node.model.name}}
34+
{{/x-tree}}
35+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Component from '@ember/component';
2+
import layout from '../templates/components/x-tree-checkbox';
3+
4+
export default Component.extend({
5+
layout,
6+
tagName: 'span',
7+
classNames: ['tree-checkbox']
8+
});

0 commit comments

Comments
 (0)