parent
87fc6f154d
commit
18194fa0f9
|
|
@ -198,6 +198,41 @@ class Table extends WidgetBase
|
|||
];
|
||||
}
|
||||
|
||||
public function onServerCreateRecord()
|
||||
{
|
||||
if ($this->isClientDataSource()) {
|
||||
throw new SystemException('The Table widget is not configured to use the server data source.');
|
||||
}
|
||||
|
||||
$this->dataSource->createRecord(
|
||||
post('recordData'),
|
||||
post('placement'),
|
||||
post('relativeToKey')
|
||||
);
|
||||
|
||||
return $this->onServerGetRecords();
|
||||
}
|
||||
|
||||
public function onServerUpdateRecord()
|
||||
{
|
||||
if ($this->isClientDataSource()) {
|
||||
throw new SystemException('The Table widget is not configured to use the server data source.');
|
||||
}
|
||||
|
||||
$this->dataSource->updateRecord(post('key'), post('recordData'));
|
||||
}
|
||||
|
||||
public function onServerDeleteRecord()
|
||||
{
|
||||
if ($this->isClientDataSource()) {
|
||||
throw new SystemException('The Table widget is not configured to use the server data source.');
|
||||
}
|
||||
|
||||
$this->dataSource->deleteRecord(post('key'));
|
||||
|
||||
return $this->onServerGetRecords();
|
||||
}
|
||||
|
||||
public function onGetDropdownOptions()
|
||||
{
|
||||
$columnName = Input::get('column');
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ServerEventDataSource extends DataSourceBase
|
|||
* Return records from the data source.
|
||||
* @param integer $offset Specifies the offset of the first record to return, zero-based.
|
||||
* @param integer $count Specifies the number of records to return.
|
||||
* @return array Returns the records.
|
||||
* @return array Returns the records.
|
||||
* If there are no more records, returns an empty array.
|
||||
*/
|
||||
public function getRecords($offset, $count)
|
||||
|
|
@ -28,6 +28,33 @@ class ServerEventDataSource extends DataSourceBase
|
|||
return $this->fireEvent('data.getCount', [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a record in the data source.
|
||||
* @return void
|
||||
*/
|
||||
public function createRecord($data, $placement, $relativeToKey)
|
||||
{
|
||||
return $this->fireEvent('data.createRecord', [$data, $placement, $relativeToKey]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a record in the data source.
|
||||
* @return void
|
||||
*/
|
||||
public function updateRecord($key, $data)
|
||||
{
|
||||
$this->fireEvent('data.updateRecord', [$key, $data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a record from the data source.
|
||||
* @return array Returns the remaining records.
|
||||
*/
|
||||
public function deleteRecord($key)
|
||||
{
|
||||
return $this->fireEvent('data.deleteRecord', [$key], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes records in the data source.
|
||||
* The method doesn't replace existing records and
|
||||
|
|
|
|||
|
|
@ -614,10 +614,13 @@ Server.prototype.constructor=Server
|
|||
Server.prototype.dispose=function(){BaseProto.dispose.call(this)
|
||||
this.data=null}
|
||||
Server.prototype.getRecords=function(offset,count,onSuccess){var handlerName=this.tableObj.getAlias()+'::onServerGetRecords'
|
||||
$.request(handlerName,{data:{offset:offset,count:count}}).done(function(data){onSuccess(data.records,data.count)})}
|
||||
Server.prototype.createRecord=function(recordData,placement,relativeToKey,offset,count,onSuccess){console.log('createRecord')}
|
||||
Server.prototype.updateRecord=function(key,recordData){console.log('updateRecord')}
|
||||
Server.prototype.deleteRecord=function(key,newRecordData,offset,count,onSuccess){console.log('deleteRecord')}
|
||||
this.tableObj.$el.request(handlerName,{data:{offset:offset,count:count}}).done(function(data){onSuccess(data.records,data.count)})}
|
||||
Server.prototype.createRecord=function(recordData,placement,relativeToKey,offset,count,onSuccess){var handlerName=this.tableObj.getAlias()+'::onServerCreateRecord'
|
||||
this.tableObj.$el.request(handlerName,{data:{recordData:recordData,placement:placement,relativeToKey:relativeToKey,offset:offset,count:count}}).done(function(data){onSuccess(data.records,data.count)})}
|
||||
Server.prototype.updateRecord=function(key,recordData){var handlerName=this.tableObj.getAlias()+'::onServerUpdateRecord'
|
||||
this.tableObj.$el.request(handlerName,{data:{key:key,recordData:recordData}})}
|
||||
Server.prototype.deleteRecord=function(key,newRecordData,offset,count,onSuccess){var handlerName=this.tableObj.getAlias()+'::onServerDeleteRecord'
|
||||
this.tableObj.$el.request(handlerName,{data:{key:key,offset:offset,count:count}}).done(function(data){onSuccess(data.records,data.count)})}
|
||||
$.oc.table.datasource.server=Server}(window.jQuery);+function($){"use strict";if($.oc.table===undefined)
|
||||
throw new Error("The $.oc.table namespace is not defined. Make sure that the table.js script is loaded.");if($.oc.table.processor===undefined)
|
||||
$.oc.table.processor={}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
*/
|
||||
Server.prototype.getRecords = function(offset, count, onSuccess) {
|
||||
var handlerName = this.tableObj.getAlias()+'::onServerGetRecords'
|
||||
$.request(handlerName, {
|
||||
this.tableObj.$el.request(handlerName, {
|
||||
data: {
|
||||
offset: offset,
|
||||
count: count
|
||||
|
|
@ -71,21 +71,18 @@
|
|||
* The onSuccess callback parameters: records, totalCount.
|
||||
*/
|
||||
Server.prototype.createRecord = function(recordData, placement, relativeToKey, offset, count, onSuccess) {
|
||||
console.log('createRecord')
|
||||
// if (placement === 'bottom') {
|
||||
// // Add record to the bottom of the dataset
|
||||
// this.data.push(recordData)
|
||||
// }
|
||||
// else if (placement == 'above' || placement == 'below') {
|
||||
// // Add record above or below the passed record key
|
||||
// var recordIndex = this.getIndexOfKey(relativeToKey)
|
||||
// if (placement == 'below')
|
||||
// recordIndex ++
|
||||
|
||||
// this.data.splice(recordIndex, 0, recordData)
|
||||
// }
|
||||
|
||||
// this.getRecords(offset, count, onSuccess)
|
||||
var handlerName = this.tableObj.getAlias()+'::onServerCreateRecord'
|
||||
this.tableObj.$el.request(handlerName, {
|
||||
data: {
|
||||
recordData: recordData,
|
||||
placement: placement,
|
||||
relativeToKey: relativeToKey,
|
||||
offset: offset,
|
||||
count: count
|
||||
}
|
||||
}).done(function(data) {
|
||||
onSuccess(data.records, data.count)
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -95,16 +92,13 @@
|
|||
* - recordData - the record fields.
|
||||
*/
|
||||
Server.prototype.updateRecord = function(key, recordData) {
|
||||
console.log('updateRecord')
|
||||
// var recordIndex = this.getIndexOfKey(key)
|
||||
|
||||
// if (recordIndex !== -1) {
|
||||
// recordData[this.tableObj.options.keyColumn] = key
|
||||
// this.data[recordIndex] = recordData
|
||||
// }
|
||||
// else {
|
||||
// throw new Error('Record with they key '+key+ ' is not found in the data set')
|
||||
// }
|
||||
var handlerName = this.tableObj.getAlias()+'::onServerUpdateRecord'
|
||||
this.tableObj.$el.request(handlerName, {
|
||||
data: {
|
||||
key: key,
|
||||
recordData: recordData
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -120,20 +114,16 @@
|
|||
* The onSuccess callback parameters: records, totalCount.
|
||||
*/
|
||||
Server.prototype.deleteRecord = function(key, newRecordData, offset, count, onSuccess) {
|
||||
console.log('deleteRecord')
|
||||
// var recordIndex = this.getIndexOfKey(key)
|
||||
|
||||
// if (recordIndex !== -1) {
|
||||
// this.data.splice(recordIndex, 1)
|
||||
|
||||
// if (this.data.length == 0)
|
||||
// this.data.push(newRecordData)
|
||||
|
||||
// this.getRecords(offset, count, onSuccess)
|
||||
// }
|
||||
// else {
|
||||
// throw new Error('Record with they key '+key+ ' is not found in the data set')
|
||||
// }
|
||||
var handlerName = this.tableObj.getAlias()+'::onServerDeleteRecord'
|
||||
this.tableObj.$el.request(handlerName, {
|
||||
data: {
|
||||
key: key,
|
||||
offset: offset,
|
||||
count: count
|
||||
}
|
||||
}).done(function(data) {
|
||||
onSuccess(data.records, data.count)
|
||||
})
|
||||
}
|
||||
|
||||
$.oc.table.datasource.server = Server
|
||||
|
|
|
|||
|
|
@ -526,7 +526,7 @@
|
|||
this.elementAddClass(this.activeCell, 'active')
|
||||
}
|
||||
|
||||
// If the cell belongs to other row than the currently edited,
|
||||
// If the cell belongs to other row than the currently edited,
|
||||
// commit currently edited row to the data source. Update the
|
||||
// currently edited row key.
|
||||
var rowKey = this.getCellRowKey(cellElement)
|
||||
|
|
|
|||
|
|
@ -2260,10 +2260,11 @@ $(window).off('.cursorLoadIndicator');}}
|
|||
$(document).ready(function(){$.oc.cursorLoadIndicator=new CursorLoadIndicator();})
|
||||
$(document).on('ajaxPromise','[data-cursor-load-indicator]',function(){$.oc.cursorLoadIndicator.show()}).on('ajaxFail ajaxDone','[data-cursor-load-indicator]',function(){$.oc.cursorLoadIndicator.hide()})}(window.jQuery);+function($){"use strict";if($.oc===undefined)
|
||||
$.oc={}
|
||||
var StripeLoadIndicator=function(){this.counter=0
|
||||
var StripeLoadIndicator=function(){var self=this
|
||||
this.counter=0
|
||||
this.indicator=$('<div/>').addClass('stripe-loading-indicator loaded').append($('<div />').addClass('stripe')).append($('<div />').addClass('stripe-loaded'))
|
||||
this.stripe=this.indicator.find('.stripe')
|
||||
$(document.body).append(this.indicator)}
|
||||
$(document).ready(function(){$(document.body).append(self.indicator)})}
|
||||
StripeLoadIndicator.prototype.show=function(){this.counter++
|
||||
this.stripe.after(this.stripe=this.stripe.clone()).remove()
|
||||
if(this.counter>1)
|
||||
|
|
@ -2275,7 +2276,7 @@ if(force!==undefined&&force)
|
|||
this.counter=0
|
||||
if(this.counter<=0){this.indicator.addClass('loaded')
|
||||
$(document.body).removeClass('loading')}}
|
||||
$(document).ready(function(){$.oc.stripeLoadIndicator=new StripeLoadIndicator()})
|
||||
$.oc.stripeLoadIndicator=new StripeLoadIndicator()
|
||||
$(document).on('ajaxPromise','[data-stripe-load-indicator]',function(event){event.stopPropagation()
|
||||
$.oc.stripeLoadIndicator.show()
|
||||
var $el=$(this)
|
||||
|
|
|
|||
Loading…
Reference in New Issue