Skip to content

Instantly share code, notes, and snippets.

View gintsgints's full-sized avatar
🏠
Working from home

Gints gintsgints

🏠
Working from home
  • Balcia SIA
  • Riga, Latvia.
View GitHub Profile
<!-- correct -->
{{#if isEditing}}
{{partial 'product/edit'}}
<button {{action 'doneEditing'}} class="btn btn-default" >Save</button>
{{else}}
{{partial 'product/view'}}
<button {{action 'edit'}} class="btn btn-default" >Edit</button>
{{/if}}
module.exports = App.Router.map(function() {
this.resource("companies", function() {
this.resource("company", {path: 'view/:company_id'}, function () {
this.route('edit');
});
this.route("new");
});
});
DS.ElasticAdapter = DS.RESTAdapter.extend({
ajax: function(url, type, hash) {
var adapter = this;
if (type == 'GET') {
url = url + "/_search"
} else {
hash.data = hash.data['company'];
};
@gintsgints
gintsgints / gist:8322494
Created January 8, 2014 19:08
Simple way of arrays
App.ArrayTransform = DS.Transform.extend({
deserialize: function(serialized) {
return serialized;
},
serialize: function(deserialized) {
return deserialized;
}
});
module.exports = App.CompaniesRoute = Ember.Route.extend({
/* model: function() {
var result = this.store.find('company');
return result;
} */
setupController: function(controller, model) {
controller.set('company', model);
}
});
@gintsgints
gintsgints / gist:8339224
Created January 9, 2014 18:21
My way for storing multiple models for route
module.exports = App.CompaniesRoute = Ember.Route.extend({
model: function() {
var result = {companies: this.store.find('company'), productgroups: this.store.find('product.group')};
return result;
}
});
/* results are returned as a promise */
promiseThen = function (httpPromise, successcb, errorcb) {
return httpPromise.then(function (response) {
(successcb || angular.noop)(response.data);
return response.data;
}, function (response) {
(errorcb || angular.noop)(response.data);
return response.data;
});
@gintsgints
gintsgints / gist:8387583
Created January 12, 2014 17:15
Dirty trick on elasticsearch
.controller('CompaniesCtrl', [
'$scope'
'$timeout'
'ejsResource'
($scope, $timeout, ejsResource) ->
ejs = ejsResource("http://localhost:9200")
client = ejs.Request().indices("emarket").types("companies")
$scope.search = ->
$scope.init = function() {
$scope.ejs = ejsResource('http://localhost:9200');
$scope.client = $scope.ejs.Request().indices('emarket').types('companies');
$scope.client.doSearch().then( function(d) {
$scope.companies = d.hits.hits;
console.log(d);
});
};
.state('companies', {
url: '/companies',
templateUrl: 'views/companies.html',
controller: 'CompaniesCtrl',
resolve: {
companies : function(ejsserver, ejsResource) {
var ejs = ejsResource(ejsserver);
var client = ejs.Request().indices('emarket').types('companies');
return client.doSearch();
}