Skip to content

Instantly share code, notes, and snippets.

@wilig
Created December 10, 2010 17:40
Show Gist options
  • Save wilig/736505 to your computer and use it in GitHub Desktop.
Save wilig/736505 to your computer and use it in GitHub Desktop.
this.publishRecordAction = new Ext.Action({
text: 'Publish',
disabled: true,
handler: function() {
if(this.getSelectedRecords().length > 0) {
var params = new Object();
params.asset_ids = this.getSelectedRecords().map(function(r) { return r.id; });
Ext.Ajax.request({
url: Imata.config.asset_publish_url(1, "publish"),
method: 'POST',
params: params,
success: function(response, opts) {
objs = Ext.util.JSON.decode(response.responseText);
Imata.log(objs);
for(var o in objs.assets) {
var id = objs.assets[o].id;
Imata.log(this.getStore());
var rec = this.getStore().getById(id);
if(rec) {
rec.data.status = objs.assets[0].status;
if(objs.assets[o].published)
rec.data.published = objs.assets[o].published
rec.commit();
}
}
var pt = this.getStore().getPublishingTarget();
var number = this.getSelectedRecords().length;
Ext.Msg.show({
title:'Pending',
msg: 'Publication Pending: ' + number + (number > 1 ? ' assets' : ' asset') + ' to <a href="' + Imata.config.collection_link(pt.id) + '" target="ARTstor_blank">' + pt.name + '</a>'
});
},
failure: function() {
Ext.Msg.alert('Server Failure', 'Server failed to publish assets');
},
scope: this
});
}
},
scope: this
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment