Skip to content

Commit

Permalink
Rewrite code to work with ember 2.10.x
Browse files Browse the repository at this point in the history
  • Loading branch information
gerard2perez committed Jan 22, 2017
1 parent c911086 commit 48cf073
Show file tree
Hide file tree
Showing 15 changed files with 240 additions and 207 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
This addon allows you to easily create a CRUD Table, it will take you only 5s!.

This component is compatible with bootstrap and ember-data.

Current Build Status for ember versions:

[![Build Status](http://travisjobsbadges.bitsun.com.mx/gerard2p/ember-cli-crudtable/filters.svg)](https://travis-ci.org/gerard2p/ember-cli-crudtable)

[![NPM Downlaads](http://img.shields.io/npm/dm/ember-cli-crudtable.svg?style=flat-square)](https://www.npmjs.org/package/ember-cli-crudtable)[![Ember Observer Score](http://emberobserver.com/badges/ember-cli-crudtable.svg?style=flat-square)](http://emberobserver.com/addons/ember-cli-crudtable)[![Issue Count](https://codeclimate.com/github/gerard2p/ember-cli-crudtable/badges/issue_count.svg)](https://codeclimate.com/github/gerard2p/ember-cli-crudtable)
Expand Down Expand Up @@ -411,7 +408,6 @@ That's all. You'll have a new field rendered as a link which is pointing to 'sch


##Upcoming
I'll create a website to show some examples if the downloads still increasing, thank you for using it.
I'll rewrite this component, I might change the name and deprecate this repo, this idea it's to make it 100% compatible with my new project [Koaton](https://github.com/gerard2p/koaton).

I'm in a little hurry but as soon as possible i'll be adding more features and also providing a more detailed doc about the functions.
But try it, is quite simple to have your fully functional CRUD application.
See you soon.
190 changes: 95 additions & 95 deletions addon/mixins/filterset.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,96 +26,96 @@ export default Ember.Mixin.create({
'==': 'Equal',
'like': 'Contains'
},
createFiltergroup(filters, link) {
let that = this;
return Ember.ArrayProxy.extend({
Link: null,
LinkLocale: Ember.computed('Link', function() {
return that.links[this.Link];
}),
isvalid: Ember.computed('[email protected]', function() {
let a = this.content.filterBy('Ready', false);
return this.content.filterBy('Ready', false).length === 0;
})
}).create({
Link: link || "or",
content: filters || [] //Ember.ArrayProxy.create()
});
},
create(base) {
let that = this;
return Ember.Object.extend({
Display: null,
Key: null,

Condition: null,
ConditionMask: Ember.computed('Condition', function() {
return (this.Options || {})[this.Condition] || "";
}),

Value: null,
ValueMask: null,

display:Ember.computed.alias('Display'),
key:Ember.computed.alias('Key'),
condition:Ember.computed.alias('Condition'),
value:Ember.computed.alias('Value'),
valuemask:Ember.computed.alias('ValueMask'),
link:Ember.computed.alias('Link'),


//Type:null,
SelectObject: false,
Options: null,
Link: null,
Readable: Ember.computed('Display', 'ConditionMask', 'ValueMask', function() {
return this.Display + " " + this.get('ConditionMask') + " " + this.ValueMask;
}),
Ready: Ember.computed('Display', 'Condition', 'Value', function() {
return !!(this.Display && this.Condition && this.Value);
// return `${this.get('Key')} ${this.get('Condition')} ${this.get('Display')}`;
}),
LinkLocale: Ember.computed('Link', function() {
return that.links[this.Link];
})
}).create(base || {});
},
init(filters) {
this.set('filtergroups', Ember.ArrayProxy.extend({
areValid: Ember.computed('[email protected]', function() {
return this.content.filterBy('isvalid', false).length === 0;
})
}).create({
content: []
}));
(filters || this.createFiltergroup().addObject(this.create())).forEach(function(filter, index, arr) {
let link = index > 0 ? arr[index - 1].link : null;
this.AddFilterGroup(filter.filters, link);
}.bind(this));
},
change(filters){
this.init(filters);
this.set('filterupdated',!this.set('filterupdated'));
},
localelink(link) {
return this.links[link];
},
makefilter(filter) {
return filter;
},
AddFilterGroup(filters, link) {
let that = this;
filters = filters || [this.create()];
link = link || "or";
filters = filters.map((filter) => {
return that.create(filter)
});
if (this.filtergroups.content.length > 0) {
let filt = this.filtergroups.objectAt(this.filtergroups.content.length - 1);
filt.set('Link', link);
}
this.filtergroups.addObject(this.createFiltergroup(filters, link));
},
// createFiltergroup(filters, link) {
// let that = this;
// return Ember.ArrayProxy.extend({
// Link: null,
// LinkLocale: Ember.computed('Link', function() {
// return that.links[this.Link];
// }),
// isvalid: Ember.computed('[email protected]', function() {
// let a = this.content.filterBy('Ready', false);
// return this.content.filterBy('Ready', false).length === 0;
// })
// }).create({
// Link: link || "or",
// content: filters || [] //Ember.ArrayProxy.create()
// });
// },
// create(base) {
// let that = this;
// return Ember.Object.extend({
// Display: null,
// Key: null,
//
// Condition: null,
// ConditionMask: Ember.computed('Condition', function() {
// return (this.Options || {})[this.Condition] || "";
// }),
//
// Value: null,
// ValueMask: null,
//
// display:Ember.computed.alias('Display'),
// key:Ember.computed.alias('Key'),
// condition:Ember.computed.alias('Condition'),
// value:Ember.computed.alias('Value'),
// valuemask:Ember.computed.alias('ValueMask'),
// link:Ember.computed.alias('Link'),
//
//
// //Type:null,
// SelectObject: false,
// Options: null,
// Link: null,
// Readable: Ember.computed('Display', 'ConditionMask', 'ValueMask', function() {
// return this.Display + " " + this.get('ConditionMask') + " " + this.ValueMask;
// }),
// Ready: Ember.computed('Display', 'Condition', 'Value', function() {
// return !!(this.Display && this.Condition && this.Value);
// // return `${this.get('Key')} ${this.get('Condition')} ${this.get('Display')}`;
// }),
// LinkLocale: Ember.computed('Link', function() {
// return that.links[this.Link];
// })
// }).create(base || {});
// },
// init(filters) {
// this.set('filtergroups', Ember.ArrayProxy.extend({
// areValid: Ember.computed('[email protected]', function() {
// return this.content.filterBy('isvalid', false).length === 0;
// })
// }).create({
// content: []
// }));
// (filters || this.createFiltergroup().addObject(this.create())).forEach(function(filter, index, arr) {
// let link = index > 0 ? arr[index - 1].link : null;
// this.AddFilterGroup(filter.filters, link);
// }.bind(this));
// },
// change(filters){
// this.init(filters);
// this.set('filterupdated',!this.set('filterupdated'));
// },
// localelink(link) {
// return this.links[link];
// },
// makefilter(filter) {
// return filter;
// },
// AddFilterGroup(filters, link) {
// let that = this;
// filters = filters || [this.create()];
// link = link || "or";
// filters = filters.map((filter) => {
// return that.create(filter)
// });
// if (this.filtergroups.content.length > 0) {
// let filt = this.filtergroups.objectAt(this.filtergroups.content.length - 1);
// filt.set('Link', link);
// }
// this.filtergroups.addObject(this.createFiltergroup(filters, link));
// },
getBody(query) {
query.filterset = (this.filtergroups||[]).map((filter) => {
return {
Expand All @@ -131,9 +131,9 @@ export default Ember.Mixin.create({
};
});
},
Query:Ember.computed('[email protected]',function(){
let query = {filterset:{}};
this.getBody(query);
return query.filterset;
})
// Query:Ember.computed('[email protected]',function(){
// let query = {filterset:{}};
// this.getBody(query);
// return query.filterset;
// })
});
27 changes: 15 additions & 12 deletions addon/privateclasses/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export default {
});
deferred = Ember.RSVP.defer('crud-table#updateRecord');
let geocoder = new google.maps.Geocoder();
geocoder.geocodefunction({
geocoder.geocode({
'latLng': map
}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
Expand Down Expand Up @@ -388,7 +388,9 @@ export default {
if (google === undefined) {
return;
}
this.set('showMap', true);
let component = this;
component.set('showMap', true);
component.set('isLoading', true);
modal.show();

function mapit(id, latlng) {
Expand All @@ -397,26 +399,27 @@ export default {
}
let mapOptions = {
zoom: latlng.zoom,
center: new google.maps.LatLng(latlng.lat, latlng.lng),
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
let map = new google.maps.Map(document.getElementById(id), mapOptions);
record.set('map', map);
component.set('isLoading', false);
return true;
}

let cord = "";
record.forEach(function(prop) {
if (prop.Type === kind) {
cord = prop.Value.split(',');
cord = (prop.Value || '20.677632,-101.341632').split(',');
cord = {
lat: cord[0],
lng: cord[1],
zoom: prop.Zoom.value
lat: parseFloat(cord[0], 10),
lng: parseFloat(cord[1], 10),
zoom: prop.Zoom.value || 11
};
}
});
let component = this;

let waitforgoogle = function(fn) {
if (google === undefined) {
setTimeout(function() {
Expand All @@ -434,7 +437,10 @@ export default {
}, 10);
}
};
waitforgoogle(waitforgoogle);
setTimeout(function(){
waitforgoogle(waitforgoogle);
},1000);

},
internal_create() {
let component = this;
Expand All @@ -443,9 +449,6 @@ export default {
let deferred = Ember.RSVP.defer('crud-table#newRecord');
component.sendAction('getRecord', deferred);
deferred.promise.then(function(record) {
// Object.keys(component.fieldDefinition).forEach(function(field) {
// record.set(field, component.fieldDefinition[field](component.get('targetObject').get('model')));
// });
if (record._internalModel !== undefined) {
records.addObject(record._internalModel);
} else {
Expand Down
2 changes: 1 addition & 1 deletion addon/privateclasses/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default {
console.log(data);
});
});
$('body').append($("#CrudTableDeleteRecordModal"));
$('[data-role=crud-table]').parent().append($("#CrudTableDeleteRecordModal"));
},
hide() {
if(this.target.modal){
Expand Down
10 changes: 6 additions & 4 deletions app/components/crud-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import Ember from 'ember';
import CRUD from 'ember-cli-crudtable/components/crud-table';
import paginator from '../paginator/crudtable';
import filterset from '../filterset/crudtable';

export default Ember.Component.extend(CRUD, {
paginator() {
return paginator.create();
},
filterset: filterset.create()
renderer: {},
filterset: filterset.create(),
paginator() {
return paginator.create();
}
});
7 changes: 5 additions & 2 deletions app/instance-initializers/google-maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ export default {
if (ENV['ember-cli-crudtable']) {
if (ENV['ember-cli-crudtable']['google-api-key']) {
window.onload = function () {
window.initMap = function () {
window.mapstarted = true;
}
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.googleapis.com/maps/api/js?key=" + ENV['ember-cli-crudtable']['google-api-key'] + "&sensor=TRUE&callback=pront";
script.src = "http://maps.googleapis.com/maps/api/js?key=" + ENV['ember-cli-crudtable']['google-api-key']+ '&callback=initMap';
document.body.appendChild(script);
}
}
}
}
};
};
2 changes: 1 addition & 1 deletion app/templates/ember-cli-crudtable/default/base.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
</div>
{{/if}}
{{yield}}
{{partial 'ember-cli-crudtable/table-modal'}}
{{partial 'ember-cli-crudtable/table-modal'}}
5 changes: 2 additions & 3 deletions app/templates/ember-cli-crudtable/default/body.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
</thead>
<tbody>
{{#unless this.isLoading}}

{{#each this.ComplexModel key="@index" as |row index|}}
{{#if row}}
<tr>
Expand All @@ -38,7 +37,7 @@
{{else}}
<tr>
<th colspan="50">
{{partial template='ember-cli-crudtable.spinner' model=this.newRecord}}
{{partial 'ember-cli-crudtable/spinner'}}
</th>
</tr>

Expand Down Expand Up @@ -74,4 +73,4 @@
{{/if}}
</tfoot>
{{/if}}
</table>
</table>
6 changes: 3 additions & 3 deletions app/templates/ember-cli-crudtable/default/top.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{{/each}}
</ul>
</div>
{{/if}}
{{/if}}
{{#if this.canRefresh}}
<button class="btn btn-default" type="button" name="refresh" title="Refresh"><i class="glyphicon glyphicon-refresh icon-refresh" {{action 'internal_reload'}}></i></button>
{{/if}} {{#if this.createRecord}}
Expand All @@ -48,10 +48,10 @@
</div>
<div class="col-sm-3">
<div class="input-group">
{{input enter="internal_search" value=this.SearchTerm placeholder="Search" class="input-sm form-control" name="SearchTerm" }}
{{input enter="internal_search" value=this.SearchTerm placeholder="Search" class="input-sm form-control" id="SearchTerm" }}
<span class="input-group-btn">
<button type="button" class="btn btn-sm btn-primary" {{action 'internal_search' this}} data-action=search> Go!</button>
</span>
</div>
</div>
{{/if}}
{{/if}}
Loading

0 comments on commit 48cf073

Please sign in to comment.