Skip to content

Commit

Permalink
Support for data pulling
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardo Perez Perez committed Apr 20, 2015
1 parent d69cbda commit 6436327
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 15 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,19 @@ And I'll be releasing a new version every month or every 5 features I add.
You can use the next command to get the latest build

```
ember install ember-cli-crudtable@tag_upper_image
ember install ember-cli-crudtable@beta
```

or

```
ember install:addon ember-cli-crudtable@tag_upper_image
ember install:addon ember-cli-crudtable@beta
```

---

##Changelog
Maybe you want one of the older relases.

### v0.4.0-beta.1
1. **fields** variable of the component now is and **object** an should be defined through the controller.
Expand Down
1 change: 1 addition & 0 deletions addon/components/crud-edit-cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default Ember.Component.extend({
return this.get('record.Value');
}.property('record'),
layoutName: function () {
console.log(this.get('record'));
return 'ember-cli-crudtable/edit-cell-' + this.get('record.Type');
}.property('record'),
parent:null,
Expand Down
35 changes: 32 additions & 3 deletions addon/components/crud-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,27 @@ var lastquery = {
page: null
};


var PULLID = 0;
var PULLFN = function(cmp,time){
return setTimeout(function(){
var deferred = Ember.RSVP.defer('crud-table#pulling');
//cmp.set('isLoading', true);
cmp.sendAction('searchRecord', {}, deferred);
deferred.promise.then(function (records) {
cmp.set('page_size',records.get('content.length') );
metadata(records, cmp);
cmp.set('value', records);
regenerateView(cmp);
//cmp.set('isLoading', false);
PULLFN(cmp,time);
}, function (data) {
alert(data.message);
//cmp.set('isLoading', false);
});
},time);
}
export default Ember.Component.extend({
pulling:false,
stripped: false,
hover: false,
createRecord: 'create',
Expand All @@ -151,6 +170,7 @@ export default Ember.Component.extend({
class: "",
fields: "id",
labels: [],
exports:true,
actions: {
toJSONObject: function () {
var data = [];
Expand Down Expand Up @@ -417,13 +437,22 @@ export default Ember.Component.extend({
this.init = function () {
that._super();
}.on('willInsertElement');
this.addObserver('pulling',function(a,b){
if( PULLID > 0 && that.get('pulling')>0 ){
clearTimeout(PULLID);
PULLID=0;
}
if(this.get('pulling')>0){
PULLID = PULLFN(that,that.get('pulling'));
}
});
}.on('willInsertElement'),
setup: function () {
var that = this;
var deferred = Ember.RSVP.defer('crud-table#createRecord');
that.set('isLoading', true);
this.sendAction('searchRecord', {}, deferred);

this.sendAction('searchRecord', {}, deferred);
$(this).addClass(this.get('class'));

deferred.promise.then(function (records) {
Expand All @@ -432,6 +461,7 @@ export default Ember.Component.extend({
that.set('value', records);
regenerateView(that);
that.set('isLoading', false);
PULLID = PULLFN(that,that.get('pulling'));
}, function (data) {
alert(data.message);
that.set('isLoading', false);
Expand All @@ -454,7 +484,6 @@ export default Ember.Component.extend({
}, function (data) {
alert(data);
});

});

}.on('didInsertElement'),
Expand Down
6 changes: 5 additions & 1 deletion addon/templates/components/crud-table.hbs
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<div class="row">
<div class="col-sm-3 m-b-xs">
{{#if createRecord}}
<button class="btn btn-primary " type="button" data-action="create" {{action 'internal_create' value}}>
<i class="fa fa-check"></i>&nbsp;New Record</button>
{{/if}}
</div>
<div class="col-sm-4 m-b-xs">
<div data-toggle="buttons" class="btn-group">
{{#if exports}}
<label id="tocsv" class="btn btn-sm btn-page" {{action 'toCSV' this}} >
<input type="radio"> To CSV </label>
<label id="totsv" class="btn btn-sm btn-page" {{action 'toTSV' this}}>
<input type="radio" id="option2" name="options"> To TSV </label>
<label id="tojson" class="btn btn-sm btn-page" {{action 'toJSONObject' this}}>
<input type="radio" id="option3" name="options"> To Json </label>
{{/if}}
</div>
</div>
<div class="col-sm-2 m-b-xs">
<div class="col-sm-2 m-b-xs no-padding">
<select id="SearchField" class="input-sm form-control input-s-sm inline">
{{#each field in this.labels}}
<option {{bind-attr value=field}}>{{field}}</option>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/ember-cli-crudtable/table-cell-googlemap.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<a {{action 'show_map' record}}>{{record.Display}}</a>
<a {{action 'show_map' record}}>{{record.Display}}</a> {{record.Type}}
15 changes: 8 additions & 7 deletions app/templates/ember-cli-crudtable/table-modal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@
</h4>
</div>
<div class="modal-body">
{{newRecord}}.{{isDeleting}}.{{showMap}}
{{#if newRecord}}
{{render 'ember-cli-crudtable/table-update' this.currentRecord}}
{{else}}
{{#if isDeleting}}
Deleting the record: <b>{{this.currentRecord.0.Value}}</b> is a permanent action.
{{else}}
{{#if isDeleting}}
Deleting the record: <b>{{this.currentRecord.0.Value}}</b> is a permanent action.
{{#if showMap}}
{{render 'ember-cli-crudtable/modal-googlemap' this.currentRecord}}
{{else}}
{{#if showMap}}
{{render 'ember-cli-crudtable/modal-googlemap' this.currentRecord}}
{{else}}
{{render 'ember-cli-crudtable/table-update' this.currentRecord}}
{{/if}}
{{render 'ember-cli-crudtable/table-update' this.currentRecord}}
{{/if}}
{{/if}}
{{/if}}
</div>
<div class="modal-footer">
{{#unless isLoading}}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-cli-crudtable",
"version": "0.4.0-beta.1",
"version": "0.4.0-beta.2",
"description": "This addon allows you to easly create a CRUD Table, it will take you only 5s!.",
"directories": {
"doc": "doc",
Expand Down

0 comments on commit 6436327

Please sign in to comment.