Skip to content

fix(root-listeners): apply listen-on-root mixin to other components #684

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

Merged
merged 43 commits into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
831f937
Add back id prop to form
Apr 7, 2017
930cc09
fix hljs padding
Apr 7, 2017
966077d
[WIP] Better tables
Apr 7, 2017
e065830
Add bootstrap -> bootstrap-vue migration notes
Apr 29, 2017
6bfe576
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Apr 30, 2017
d0ffd9c
add bFormFieldset label text alignment options
Apr 30, 2017
59f5b2a
fixes per @pi0
Apr 30, 2017
3bd489c
add focus method proxied to element ref
Apr 30, 2017
5ddeacd
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 2, 2017
d9a9758
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 9, 2017
ce99129
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 16, 2017
fd91ee2
Popover dom node leak fix
May 16, 2017
8b5fa59
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 16, 2017
4dd826a
Merge branch 'issue-329' of github.com:alexsasharegan/bootstrap-vue
May 16, 2017
f2f3ac0
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 18, 2017
0ad12f2
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 18, 2017
f66ac26
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 18, 2017
8955737
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 20, 2017
0b4433b
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 21, 2017
259a51c
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 24, 2017
cabfc7d
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 25, 2017
049d294
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 26, 2017
9fe3803
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
May 27, 2017
70f12d1
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jun 5, 2017
912d40b
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jun 17, 2017
50c440e
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jun 23, 2017
4191086
feat(mixin): Automate event registration & removal on root vm
Jun 29, 2017
fe9224c
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jun 29, 2017
75f1eaf
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jun 30, 2017
8495db0
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jun 30, 2017
aa6d108
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jun 30, 2017
552806e
fix(button-toolbar): Typo on property `keyNav`
Jun 30, 2017
bc84b33
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jun 30, 2017
70b8a61
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jul 2, 2017
7e5143e
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jul 6, 2017
f50eec8
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jul 6, 2017
4c06827
Merge branch 'tables' of https://github.com/bootstrap-vue/bootstrap-vue
Jul 6, 2017
1c9a66a
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jul 6, 2017
4a93edd
Merge branch 'master' of https://github.com/bootstrap-vue/bootstrap-vue
Jul 9, 2017
2afa15c
fix(root-listeners): apply listen-on-root mixin to other components
Jul 11, 2017
a198311
fix(docs): table readme pull from master
Jul 11, 2017
d31a99e
fix(form): pull current master
Jul 11, 2017
1a5020d
fix: remove adapter utils
Jul 11, 2017
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
26 changes: 13 additions & 13 deletions docs/components/table/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ custom rendering, events, and asynchronous data.
<pre>{{ modalDetails.data }}</pre>
</b-modal>

</div>
</div>
</template>

<script>
Expand Down Expand Up @@ -130,7 +130,7 @@ export default {
```

### `fields` prop
The `fields` prop is used to display table columns.
The `fields` prop is used to display table columns.
Keys are used to extract real value from each row.
Example format:
```js
Expand Down Expand Up @@ -175,7 +175,7 @@ in the Vue.js guide.
name: 'Havij'
},
{
_cellVariants: {
_cellVariants: {
age: 'danger', // Displayes cell for field 'age' red
name: 'success' // Displayes cell for field 'name' green
},
Expand All @@ -198,7 +198,7 @@ the record, will be prefered.

`items` can also be a reference to a *provider* function, which returns an `Array` of items data.
Provider functions can also be asynchronous:
- By returning `null` (or `undefined`) and calling a callback, when the data is
- By returning `null` (or `undefined`) and calling a callback, when the data is
ready, with the data array as the only argument to the callback,
- By returning a `Promise` that resolves to an array.

Expand Down Expand Up @@ -297,7 +297,7 @@ The slot's scope variable (`data` in the above sample) will have the following p
| `item` | Object | The entire record (i.e. `items[index]`) for this row
| `index` | Number | The row number (zero based)

**Note** that `index` will not always be the actual row's index number, as it is
**Note** that `index` will not always be the actual row's index number, as it is
computed after pagination and filtering have been applied to the original
table data. The `index` value will refer to the **displayed row number**. This
number will align with the indexes from the optional `v-model` bound variable.
Expand Down Expand Up @@ -344,8 +344,8 @@ If you bind a variable to the `v-model` prop, the contents of this variable will
be the currently disaplyed item records (zero based index, up to `page-size` - 1).
This variable (the `value` prop) should usually be treated as readonly.

The records within the v-model are a filtered/paginated shallow copy of `items`, and
hence any changes to a record's properties in the v-model will be reflected in
The records within the v-model are a filtered/paginated shallow copy of `items`, and
hence any changes to a record's properties in the v-model will be reflected in
the original `items` array (except when `items` is set to a provider function).
Deleteing a record from the v-model will **not** remove the record from the
original items array.
Expand All @@ -372,7 +372,7 @@ The built-in default `sort-compare` function sorts the specified field `key` bas
on the data in the underlying record object. The field value is first stringified
if it is an object, and then sorted.

The default `sort-compare` routine **cannot** sort neither virtual columns, nor
The default `sort-compare` routine **cannot** sort neither virtual columns, nor
based on the custom rendering of the field data (which is used only for presentation).
For this reason, you can provide your own custom sort compare routine by passing a
function reference to the prop `sort-compare`.
Expand Down Expand Up @@ -402,7 +402,7 @@ if (typeof a[key] === 'number' && typeof b[key] === 'number') {
```

### Using Items Provider Functions
As mentioned under the `items` prop section, it is possible to use a function to provide
As mentioned under the `items` prop section, it is possible to use a function to provide
the row data (items), by specifying a function reference via the `items` prop.

**Note:** The `items-provider` prop has been deprecated in favour of providing a function
Expand Down Expand Up @@ -433,7 +433,7 @@ function myProvider(ctx) {
let items = [];

// perform any items processing needed

// Must return an array
return items || [];
}
Expand Down Expand Up @@ -471,7 +471,7 @@ function myProvider(ctx) {
}
```

`<b-table>` provides a `busy` prop that will flag the table as busy, which you can
`<b-table>` provides a `busy` prop that will flag the table as busy, which you can
set to `true` just before your async fetch, and then set it to `false` once you have
your data, and just before you send it to the table for display. Example:

Expand Down Expand Up @@ -499,7 +499,7 @@ methods: {
}
```

By default, the items provider function is responsible for **all paging, filtering, and sorting**
By default, the items provider function is responsible for **all paging, filtering, and sorting**
of the data, before passing it to `b-table` for display.

You can disable provider paging, filtering, and sorting (individually) by setting the
Expand All @@ -520,7 +520,7 @@ trigger the calling of the provider function. So be sure to bind to the `per-pa
(unless you have the respective `no-provider-*` prop set to `true`).

#### Event based refreshing of data:
You may also trigger the refresh of the provider function by emitting the
You may also trigger the refresh of the provider function by emitting the
event `table::refresh` on `$root` with the single argument being the `id` of your `b-table`.
You must have a unique ID on your table for this to work.

Expand Down
8 changes: 5 additions & 3 deletions lib/components/table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@

<script>
import { warn } from '../utils';
import { keys } from '../utils/object.js'
import { keys } from '../utils/object.js';
import { listenOnRootMixin } from '../mixins'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semicolon? 😜

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahaha

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goodness, look at me. I tried to fight my editor prefs and add a semicolon, and then I forget it in the very next line!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha!


const toString = v => {
if (!v) {
Expand Down Expand Up @@ -117,6 +118,7 @@
};

export default {
mixins: [listenOnRootMixin],
data() {
return {
sortBy: null,
Expand Down Expand Up @@ -278,7 +280,7 @@
if (this.hasProvider) {
this._providerUpdate();
}
this.$root.$on('table::refresh', (id) => {
this.listenOnRoot('table::refresh', (id) => {
if (id === this.id) {
this._providerUpdate();
}
Expand Down Expand Up @@ -478,7 +480,7 @@
_providerSetLocal(items) {
this.localItems = (items && items.length > 0) ? items.slice() : [];
this.$emit('refreshed');
this.$root.$emit('table::refreshed', this.id);
this.emitOnRoot('table::refreshed', this.id);
},
_providerUpdate() {
// Refresh the provider items
Expand Down
12 changes: 7 additions & 5 deletions lib/mixins/dropdown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import clickOut from './clickout';
import listenOnRootMixin from './listen-on-root'
import { from as arrayFrom } from '../utils/array'

// Determine if an HTML element is visible - Faster than CSS check
Expand All @@ -17,6 +18,7 @@ const HEADER_SELECTOR = '.dropdown-header';
const ALL_SELECTOR = [ITEM_SELECTOR, HEADER_SELECTOR].join(',');

export default {
mixins: [listenOnRootMixin],
props: {
id: {
type: String
Expand Down Expand Up @@ -51,10 +53,10 @@ export default {
};

// To keep one dropdown opened on page
this.$root.$on('shown::dropdown', listener);
this.listenOnRoot('shown::dropdown', listener);

// Hide when clicked on links
this.$root.$on('clicked::link', listener);
this.listenOnRoot('clicked::link', listener);
},
mounted: clickOut.mounted,
destroyed: clickOut.destroyed,
Expand All @@ -65,7 +67,7 @@ export default {
}

if (state) {
this.$root.$emit('shown::dropdown', this);
this.emitOnRoot('shown::dropdown', this);
/*
If this is a touch-enabled device we add extra
empty mouseover listeners to the body's immediate children;
Expand All @@ -79,7 +81,7 @@ export default {
});
}
} else {
this.$root.$emit('hidden::dropdown', this);
this.emitOnRoot('hidden::dropdown', this);
/*
If this is a touch-enabled device we remove the extra
empty mouseover listeners we added for iOS support
Expand Down Expand Up @@ -108,7 +110,7 @@ export default {
}
if (this.split) {
this.$emit('click', e);
this.$root.$emit('shown::dropdown', this);
this.emitOnRoot('shown::dropdown', this);
} else {
this.toggle();
}
Expand Down
8 changes: 5 additions & 3 deletions lib/mixins/popover.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Tether from 'tether';
import listenOnRootMixin from './listen-on-root'
import { isArray, arrayIncludes } from '../utils/array';
import { keys } from '../utils/object';

Expand All @@ -22,6 +23,7 @@ const TETHER_CLASSES = {
const TRANSITION_DURATION = 150;

export default {
mixins: [listenOnRootMixin],
props: {
constraints: {
type: Array,
Expand Down Expand Up @@ -315,10 +317,10 @@ export default {
this.$emit('showChange', newShowState);
if (newShowState) {
this.showPopover();
this.$root.$emit('shown::popover');
this.emitOnRoot('shown::popover');
} else {
this.hidePopover();
this.$root.$emit('hidden::popover');
this.emitOnRoot('hidden::popover');
}
},
/**
Expand Down Expand Up @@ -347,7 +349,7 @@ export default {
}
},
created() {
this.$root.$on('hide::popover', () => {
this.listenOnRoot('hide::popover', () => {
this.triggerState = false;
});
},
Expand Down