From 9645d50912677828515c543d76de50d0f0f05691 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Fri, 8 Apr 2011 01:16:07 -0400 Subject: Entitlements. --- install/ui/entitle.js | 196 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 install/ui/entitle.js (limited to 'install/ui/entitle.js') diff --git a/install/ui/entitle.js b/install/ui/entitle.js new file mode 100644 index 000000000..3f62860c5 --- /dev/null +++ b/install/ui/entitle.js @@ -0,0 +1,196 @@ +/*jsl:import ipa.js */ + +/* Authors: + * Endi S. Dewata + * + * Copyright (C) 2010 Red Hat + * see file 'COPYING' for use and warranty information + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ + + +IPA.entitle = {}; + +IPA.entity_factories.entitle = function() { + + var builder = IPA.entity_builder(); + + builder. + entity('entitle'). + facet({ + factory: IPA.entitle.search_facet, + columns: [ + { + name: 'product', + label: 'Product' + }, + { + name: 'quantity', + label: 'Quantity' + }, + { + name: 'start', + label: 'Start' + }, + { + name: 'end', + label: 'End' + } + ], + search_all: true + }). + dialog({ + factory: IPA.entitle.consume_dialog, + name: 'consume', + title: 'Consume Entitlements', + fields: [ + { + name: 'quantity', + label: 'Quantity', + undo: false + } + ] + }). + details_facet({ + sections: [ + { + name: 'identity', + label: IPA.messages.details.identity, + fields: ['ipaentitlementid'] + } + ] + }). + standard_association_facets(); + + return builder.build(); +}; + +IPA.entitle.search_facet = function(spec) { + + spec = spec || {}; + + var that = IPA.search_facet(spec); + + that.create_action_panel = function(container) { + + that.facet_create_action_panel(container); + + var li = $('.action-controls', container); + + var buttons = $('', { + 'class': 'search-buttons' + }).appendTo(li); + + $('', { + type: 'button', + name: 'consume', + value: 'Consume' + }).appendTo(buttons); + }; + + that.setup = function(container) { + + that.search_facet_setup(container); + + var action_panel = that.get_action_panel(); + + var button = $('input[name=consume]', action_panel); + that.consume_button = IPA.action_button({ + label: 'Consume', + icon: 'ui-icon-plus', + click: function() { + var dialog = that.get_dialog('consume'); + dialog.open(that.container); + } + }); + button.replaceWith(that.consume_button); + }; + + that.refresh = function() { + + function on_success(data, text_status, xhr) { + + that.table.empty(); + + var result = data.result.result; + for (var i = 0; iError: '+error_thrown.name+'

'); + summary.append('

'+error_thrown.title+'

'); + summary.append('

'+error_thrown.message+'

'); + } + + var command = IPA.command({ + method: 'entitle_get', + options: { + all: that.search_all + }, + on_success: on_success, + on_error: on_error + }); + + command.execute(); + }; + + return that; +}; + +IPA.entitle.consume_dialog = function(spec) { + + spec = spec || {}; + + var that = IPA.dialog(spec); + + that.add_button('Consume', function() { + var record = {}; + that.save(record); + + var command = IPA.command({ + method: 'entitle_consume', + args: [ record.quantity ], + on_success: function() { + var entity = IPA.get_entity(that.entity_name); + var facet = entity.get_facet('search'); + facet.table.refresh(); + that.close(); + } + }); + + command.execute(); + }); + + that.add_button('Cancel', function() { + that.close(); + }); + + return that; +}; -- cgit