Skip to content

Releases: vinayakkulkarni/vuejs-sort

Minor Changes

01 Sep 09:06
Compare
Choose a tag to compare
  • Props changed
  • Uses more sophisticated code at the backend
  • Still dependent on 'asc' & 'desc' (need to fix it)

Minor Changes - Using vue-router

01 Sep 09:05
Compare
Choose a tag to compare

Minor Changes

01 Sep 09:04
Compare
Choose a tag to compare
1.0.4

1.0.4

Minor Fixes

31 Aug 11:29
Compare
Choose a tag to compare
  • Fixed the issue where Vue squawks Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.

Minor Patch Fixes

31 Aug 11:23
Compare
Choose a tag to compare
  • Fixed README & tests

Init 6

31 Aug 11:19
Compare
Choose a tag to compare

Build Status

VueJS Sort ⚡

  • A simple Vue.js sorting wrapper.

  • This is on GitHub so let me know if I've b0rked it somewhere, give me a star ⭐ if you like it 🍻

Requirements

✅ Install 👌

npm install vuejs-sort
// or
yarn add vuejs-sort

✅ Usage 🎓

Register the component globally:

Vue.component('sort', require('vuejs-sort'));

Or use locally

import sort from 'vuejs-sort';

✅ Example 🍀

<sort :data="sortingData" label="Name" icon="chevron" v-on:sort-data="sortData"></sort>
Vue.component('example-component', {

	data() {
		return {
			// Our data object that holds the Sorting data
			sortingData: {},
		}
	},

	created() {
		// Fetch initial results
		this.sortData();
	},

	methods: {
		// Our method to GET results from a Laravel endpoint
		sortData(sort, direction) {
			if (typeof sort === 'undefined') {
				sort = 1;
			}

			// Using vue-resource as an example
			this.$http.get('example/results?sort=' + page + '&direction=' + direction)
				.then(response => {
					return response.json();
				}).then(data => {
					this.sortingData = data;
				});
		}
	}

});

✅ 📖 Props

Name Type Description
data Object An object containing sort (you can set this at your backend) & sorttype (viz. Direction eg. 'asc', 'desc')
icon String (optional) Default is chevron; Refer Semantic-UI Icons for specifying which icons you want.
label String (optional) Is responsible for the label that'll be displayed which will be clickable.
{
	sort: 1,
	sorttype: 'asc',
}

✅ 👂 Events

Name Description
sort-data Triggered when a user changes sort & sorttype.

NPM :octocat:

NPM