import Ember from 'ember';

export default Ember.Controller.extend({
	queryParams: ['active', 'sortProperties', 'match'],
	active: null,
	order: 'asc',
	match: '*',

	sortProperty: 'title',
	sortOrder: 'asc',
	sortProperties: Ember.computed('sortProperty', 'sortOrder', function() {
		if (this.get('sortProperty') == null) {
			return null
		}
		return [`${this.get('sortProperty')}:${this.get('sortOrder')}`];
	}),
	toggleOrder: function(order) {
		if (order === 'asc') {
    		this.set('sortOrder', 'desc'); 
    	} else {
    		this.set('sortOrder', 'asc');
    	}
	},
	actions: {
	    selectStatusFilter: function(status) {
	      	this.set('active', status);
	      	this.set('sortProperty', 'title');
	      	this.set('sortOrder', 'asc');
	    },
	    sortingMethod: function(sortProperty) {
	    	if (this.get('sortProperty') === sortProperty) {
	    		this.toggleOrder(this.get('sortOrder'));
	    	} else {
	    		this.set('sortOrder', 'asc');
	    	}
	      	this.set('sortProperty', sortProperty);
	    },
	    resetParams: function() {
	    	this.set('active', null);
	      	this.set('match', '*');
	      	this.set('sortProperty', 'title');
	      	this.set('order', 'asc');
	    },
	    updateSearch: function(value) {
	    	this.set('match', value);
	    	this.set('sortProperty', null);
	    },
	}
});

@@ -134,23 +134,8 @@
 ll,%0A
-%09order: 'asc',%0A
 %09mat
@@ -143,16 +143,16 @@
 h: '*',%0A
+
 %0A%09sortPr
@@ -257,24 +257,36 @@
 unction() %7B%0A
+%09%09debugger;%0A
 %09%09if (this.g
@@ -343,17 +343,16 @@
 %09return 
-%5B
 %60$%7Bthis.
@@ -397,17 +397,16 @@
 rder')%7D%60
-%5D
 ;%0A%09%7D),%0A%09
@@ -997,16 +997,52 @@
 perty);%0A
+%09      %09this.get('sortProperties');%0A
 %09    %7D,%0A
@@ -1197,17 +1197,21 @@
 is.set('
-o
+sortO
 rder', '

remove typos