def get_child_codes(self, parent_collection_code, search_type): ''' All of the children's codes down the relationship tree of the collection will be returned. ''' from pyasm.biz import Project project = Project.get() sql = project.get_sql() impl = project.get_database_impl() search_codes = [] parts = search_type.split("/") collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1]) # Check if connection between asset and asset_in_asset is in place if collection_type not in SearchType.get_related_types(search_type): return search_codes stmt = impl.get_child_codes_cte(collection_type, search_type, parent_collection_code) results = sql.do_query(stmt) for result in results: result = "".join(result) search_codes.append(result) return search_codes
def delete_sobject(my, sobject): search_type = sobject.get_base_search_type() # this is used by API method delete_sobject auto_discover = my.kwargs.get("auto_discover") values = my.kwargs.get("values") if values: related_types = values.get("related_types") elif auto_discover: related_types = SearchType.get_related_types(search_type, direction="children") else: related_types = None # always delete notes and task and snapshot #if not related_types: # related_types = ['sthpw/note', 'sthpw/task', 'sthpw/snapshot'] #related_types = my.schema.get_related_search_types(search_type) if related_types: for related_type in related_types: if not related_type or related_type == search_type: continue # snapshots take care of sthpw/file in the proper manner, so # skip them here if related_type == 'sthpw/file': continue related_sobjects = sobject.get_related_sobjects(related_type) for related_sobject in related_sobjects: if related_type == 'sthpw/snapshot': my.delete_snapshot(related_sobject) else: related_sobject.delete() # implicitly remove "directory" files associated with the sobject search = Search("sthpw/file") search.add_op("begin") search.add_filter("file_name", "") search.add_null_filter("file_name") search.add_op("or") search.add_parent_filter(sobject) file_objects = search.get_sobjects() for file_object in file_objects: base_dir = Environment.get_asset_dir() relative_dir = file_object.get("relative_dir") lib_dir = "%s/%s" % (base_dir, relative_dir) print "removing: ", lib_dir FileUndo.rmdir(lib_dir) file_object.delete() # finally delete the sobject print "deleting: ", sobject.get_search_key() if search_type == 'sthpw/snapshot': my.delete_snapshot(sobject) else: sobject.delete()
def delete_sobject(self, sobject): search_type = sobject.get_base_search_type() # this is used by API method delete_sobject auto_discover = self.kwargs.get("auto_discover") values = self.kwargs.get("values") if values: related_types = values.get("related_types") elif auto_discover: related_types = SearchType.get_related_types(search_type, direction="children") else: related_types = None return self.do_delete(sobject, related_types)
def get_display(self): top = self.top self.set_as_panel(top) top.add_class("spt_delete_top") top.add_color("background", "background") top.add_color("color", "color") top.add_border() top.add_style("width: 400px") top.add_border() search_key = self.kwargs.get("search_key") search_keys = self.kwargs.get("search_keys") if search_key: sobject = Search.get_by_search_key(search_key) sobjects = [sobject] search_keys = [search_key] elif search_keys: sobjects = Search.get_by_search_keys(search_keys) sobject = sobjects[0] if not sobjects or not sobject: msg = "%s not found" %search_key return msg search_type = sobject.get_base_search_type() if search_type in ['sthpw/project', 'sthpw/search_object']: msg = 'You cannot delete these items with this tool' return msg self.search_keys = search_keys title = DivWdg() top.add(title) icon = IconWdg("WARNING", IconWdg.WARNING) icon.add_style("float: left") title.add(icon) if len(self.search_keys) > 1: title.add("Delete %s Items" % len(self.search_keys)) else: title.add("Delete Item [%s]" % (sobject.get_code())) title.add_style("font-size: 20px") title.add_style("font-weight: bold") title.add_style("padding: 10px") title.add("<hr/>") content = DivWdg() top.add(content) content.add_style("margin: 5px 10px 20px 10px") content.add("The item to be deleted has a number of dependencies as described below:<br/>", 'heading') # find all the relationships related_types = SearchType.get_related_types(search_type, direction='children') items_div = DivWdg() content.add( items_div ) items_div.add_style("padding: 10px") valid_related_ctr = 0 for related_type in related_types: if related_type == "*": print("WARNING: related_type is *") continue if related_type == search_type: continue if related_type in ['sthpw/search_object','sthpw/search_type']: continue item_div = self.get_item_div(sobjects, related_type) if item_div: items_div.add(item_div) valid_related_ctr += 1 if valid_related_ctr > 0: #icon = IconWdg("Note", "BS_NOTE") #icon.add_style("float: left") #content.add( icon ) content.add("<div><b>By selecting the above, the corresponding related items will be deleted as well.</b></div>") content.add("<br/>"*2) else: # changed the heading to say no dependencies content.add("The item to be deleted has no dependencies.<br/>", 'heading') num_items = len(self.search_keys) if num_items == 1: verb = "is 1 item" else: verb = "are %s items" % num_items content.add("There %s to be deleted" % verb) content.add("<br/>"*2) content.add("Do you wish to continue deleting?") content.add("<br/>"*3) button_div = DivWdg() button_div.add_class("spt_buttons") content.add(button_div) button_div.add_style('text-align: center') button = ActionButtonWdg(title="Delete", width=100, color="danger") button_div.add(button) button.add_style("display: inline-block") deleting_div = DivWdg() content.add(deleting_div) deleting_div.add("<img src='/context/icons/common/indicator_snake.gif'/>") deleting_div.add_class("spt_delete_msg") deleting_div.add(" Deleting ...") deleting_div.add_style("text-align: center") deleting_div.add_style("font-size: 16px") deleting_div.add_style("margin: 20px") deleting_div.add_style("display: none") on_complete = self.kwargs.get("on_complete") button.add_behavior( { 'type': 'click_up', 'search_keys': self.search_keys, 'on_complete': on_complete, 'cbjs_action': ''' spt.app_busy.show("Deleting"); //spt.notify.show_message("Deleting ..."); //var button_el = bvr.src_el.getParent(".spt_buttons"); //button_el.setStyle("display", "none"); var top = bvr.src_el.getParent(".spt_delete_top"); var values = spt.api.Utility.get_input_values(top); var class_name = "tactic.ui.tools.DeleteCmd"; var kwargs = { 'search_keys': bvr.search_keys, 'values': values }; var del_trigger = function() { // for fast table var tmps = spt.split_search_key(bvr.search_keys[0]) var tmps2 = tmps[0].split('?'); var del_st_event = "delete|" + tmps2[0]; var bvr_fire = {}; var input = {'search_keys': bvr.search_keys}; bvr_fire.options = input; spt.named_events.fire_event(del_st_event, bvr_fire); } var server = TacticServerStub.get(); server.execute_cmd(class_name, kwargs, null, { on_complete: function() { //spt.notify.show_message("Finshed deleting ..."); // run the post delete and destroy the popup var popup = bvr.src_el.getParent(".spt_popup"); if (popup.spt_on_post_delete) { popup.spt_on_post_delete(); } del_trigger(); spt.popup.destroy(popup); if (bvr.on_complete) { on_complete = function() { eval(bvr.on_complete); } on_complete(); } spt.app_busy.hide(); }, on_error: function(e) { spt.notify.show_message("Error on delete"); spt.alert(spt.exception.handler(e)); spt.app_busy.hide(); } } ); ''' } ) button = ActionButtonWdg(title="Cancel", width=100) button_div.add(button) button.add_style("display: inline-block") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_popup"); top.destroy(); ''' } ) content.add("<br clear='all'/>") return top
def get_display(my): top = my.top my.set_as_panel(top) top.add_class("spt_delete_top") top.add_color("background", "background") top.add_color("color", "color") top.add_border() top.add_style("width: 300px") top.add_border() search_key = my.kwargs.get("search_key") search_keys = my.kwargs.get("search_keys") if search_key: sobject = Search.get_by_search_key(search_key) sobjects = [sobject] search_keys = [search_key] elif search_keys: sobjects = Search.get_by_search_keys(search_keys) sobject = sobjects[0] if not sobjects: msg = "%s not found" % search_key return msg search_type = sobject.get_base_search_type() if search_type in ['sthpw/project', 'sthpw/search_object']: msg = 'You cannot delete these items with this tool' return msg my.search_keys = search_keys title = DivWdg() top.add(title) title.add_color("background", "background", -10) if my.search_keys: title.add("Delete %s Items" % len(my.search_keys)) else: title.add("Delete Item [%s]" % (sobject.get_code())) title.add_style("font-size: 14px") title.add_style("font-weight: bold") title.add_style("padding: 10px") content = DivWdg() top.add(content) content.add_style("padding: 10px") content.add( "The item to be deleted has a number of dependencies as described below:<br/>", 'heading') # find all the relationships related_types = SearchType.get_related_types(search_type, direction='children') items_div = DivWdg() content.add(items_div) items_div.add_style("padding: 10px") valid_related_ctr = 0 for related_type in related_types: if related_type == "*": print "WARNING: related_type is *" continue if related_type == search_type: continue if related_type in ['sthpw/search_object', 'sthpw/search_type']: continue item_div = my.get_item_div(sobjects, related_type) if item_div: items_div.add(item_div) valid_related_ctr += 1 if valid_related_ctr > 0: icon = IconWdg("WARNING", IconWdg.WARNING) icon.add_style("float: left") content.add(icon) content.add( "<div><b>WARNING: By selecting the related items above, you can delete them as well when deleting this sObject.</b></div>" ) content.add("<br/>" * 2) else: # changed the heading to say no dependencies content.add("The item to be deleted has no dependencies.<br/>", 'heading') content.add("There are %s items to be deleted" % len(my.search_keys)) content.add("<br/>" * 2) content.add("Do you wish to continue deleting?") content.add("<br/>" * 2) button_div = DivWdg() button_div.add_styles('width: 300px; height: 75px') button = ActionButtonWdg(title="Delete") button_div.add(button) content.add(button_div) button.add_style("float: left") button.add_behavior({ 'type': 'click_up', 'search_keys': my.search_keys, 'cbjs_action': ''' spt.app_busy.show("Deleting"); var top = bvr.src_el.getParent(".spt_delete_top"); var values = spt.api.Utility.get_input_values(top); var class_name = "tactic.ui.tools.DeleteCmd"; var kwargs = { 'search_keys': bvr.search_keys, 'values': values }; var del_trigger = function() { // for fast table var tmps = spt.split_search_key(bvr.search_keys[0]) var tmps2 = tmps[0].split('?'); var del_st_event = "delete|" + tmps2[0]; var bvr_fire = {}; var input = {'search_keys': bvr.search_keys}; bvr_fire.options = input; spt.named_events.fire_event(del_st_event, bvr_fire); } var server = TacticServerStub.get(); try { server.start({'title': 'Delete sObject', 'description': 'Delete sObject [' + bvr.search_keys + ']'}); server.execute_cmd(class_name, kwargs); server.finish(); // run the post delete and destroy the popup var popup = bvr.src_el.getParent(".spt_popup"); if (popup.spt_on_post_delete) { popup.spt_on_post_delete(); } del_trigger(); spt.popup.destroy(popup); } catch(e) { spt.alert(spt.exception.handler(e)); } spt.app_busy.hide(); ''' }) button = ActionButtonWdg(title="Cancel") button.add_style("float: left") button_div.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_popup"); top.destroy(); ''' }) content.add("<br clear='all'/>") return top
def update_collection_keywords(self, mode, base_search_type, input): ''' When there is an entry being added or removed in the asset_in_asset table (ie. adding asset to collection, removing asset from collection, or deleting a collection), the "collection" data set in the keywords_data needs to be updated. ''' # this is only for collections types stype_obj = SearchType.get(base_search_type) if stype_obj.get_value('type') != 'collection': return asset_in_asset_sobject = input.get("sobject") asset_stypes = SearchType.get_related_types(base_search_type, direction="parent") if not asset_stypes: return asset_stype = asset_stypes[0] parent_code = asset_in_asset_sobject.get("parent_code") search_code = asset_in_asset_sobject.get("search_code") parent_sobject = Search.get_by_code(asset_stype, parent_code) child_sobject = Search.get_by_code(asset_stype, search_code) collection_keywords_dict = {} parent_collection_keywords_dict = {} # Existing "collection" keywords in child's keywords_data child_keywords_data = child_sobject.get_json_value("keywords_data", {}) if isinstance(child_keywords_data, basestring): raise TacticException("Invalid data found in keywords_data for %s. Please notify site administrator to correct it."%child_sobject.get_code()) # check for old data structure with only keywords filled and initialize if necessary if not child_keywords_data: user_keywords = child_sobject.get_value('user_keywords') original_keywords = child_sobject.get_value('keywords') if original_keywords and not user_keywords: # initiatize keywords_data in this case child_keywords_data['user'] = original_keywords child_sobject.set_value('user_keywords', original_keywords) # Existing "collection" keywords in parent's keywords_data parent_keywords_data = parent_sobject.get_json_value("keywords_data", {}) # keywords of parent parent_collection_keywords = parent_keywords_data.get('user') if 'collection' in child_keywords_data: collection_keywords_dict = child_keywords_data.get('collection') if 'collection' in parent_keywords_data: parent_collection_keywords_dict = parent_keywords_data.get('collection') if mode == "insert": # Add parent's user defined keywords if parent_collection_keywords: collection_keywords_dict[parent_code] = parent_collection_keywords # Also append parent's "collection" keywords_data collection_keywords_dict.update(parent_collection_keywords_dict) # Find all children that has [search_code] in their collection's keys # and update child_codes = self.get_child_codes(search_code, asset_stype) if child_codes: child_nest_sobjects = Search.get_by_code(asset_stype, child_codes) for child_nest_sobject in child_nest_sobjects: child_nest_collection_keywords_data = child_nest_sobject.get_json_value("keywords_data", {}) child_nest_collection_keywords = child_nest_collection_keywords_data['collection'] child_nest_collection_keywords.update(collection_keywords_dict) child_nest_sobject.set_json_value("keywords_data", child_nest_collection_keywords_data) child_nest_sobject.commit(triggers=False) self.set_searchable_keywords(child_nest_sobject) elif mode == "delete": child_codes = [] if parent_code in collection_keywords_dict: # Remove "collection" keywords_data from child with key matching parent_code del collection_keywords_dict[parent_code] # Also need to remove parent's "collection" keywords_data from child for key in parent_collection_keywords_dict.keys(): del collection_keywords_dict[key] child_codes = self.get_child_codes(search_code, asset_stype) if child_codes: child_nest_sobjects = Search.get_by_code(asset_stype, child_codes) for child_nest_sobject in child_nest_sobjects: child_nest_collection_keywords_data = child_nest_sobject.get_json_value("keywords_data", {}) child_nest_collection_keywords = child_nest_collection_keywords_data['collection'] if parent_code in child_nest_collection_keywords: del child_nest_collection_keywords[parent_code] child_nest_sobject.set_json_value("keywords_data", child_nest_collection_keywords_data) child_nest_sobject.commit(triggers=False) self.set_searchable_keywords(child_nest_sobject) child_keywords_data['collection'] = collection_keywords_dict child_sobject.set_json_value("keywords_data", child_keywords_data) child_sobject.commit(triggers=False) self.set_searchable_keywords(child_sobject)
def get_display(my): top = my.top my.set_as_panel(top) top.add_class("spt_delete_top") top.add_color("background", "background") top.add_color("color", "color") top.add_border() top.add_style("width: 300px") top.add_border() search_key = my.kwargs.get("search_key") search_keys = my.kwargs.get("search_keys") if search_key: sobject = Search.get_by_search_key(search_key) sobjects = [sobject] search_keys = [search_key] elif search_keys: sobjects = Search.get_by_search_keys(search_keys) sobject = sobjects[0] if not sobjects: msg = "%s not found" %search_key return msg search_type = sobject.get_base_search_type() if search_type in ['sthpw/project', 'sthpw/search_object']: msg = 'You cannot delete these items with this tool' return msg my.search_keys = search_keys title = DivWdg() top.add(title) title.add_color("background", "background", -10) if my.search_keys: title.add("Delete %s Items" % len(my.search_keys)) else: title.add("Delete Item [%s]" % (sobject.get_code())) title.add_style("font-size: 14px") title.add_style("font-weight: bold") title.add_style("padding: 10px") content = DivWdg() top.add(content) content.add_style("padding: 10px") content.add("The item to be deleted has a number of dependencies as described below:<br/>", 'heading') # find all the relationships related_types = SearchType.get_related_types(search_type, direction='children') items_div = DivWdg() content.add( items_div ) items_div.add_style("padding: 10px") valid_related_ctr = 0 for related_type in related_types: if related_type == "*": print "WARNING: related_type is *" continue if related_type == search_type: continue if related_type in ['sthpw/search_object','sthpw/search_type']: continue item_div = my.get_item_div(sobjects, related_type) if item_div: items_div.add(item_div) valid_related_ctr += 1 if valid_related_ctr > 0: icon = IconWdg("WARNING", IconWdg.WARNING) icon.add_style("float: left") content.add( icon ) content.add("<div><b>WARNING: By selecting the related items above, you can delete them as well when deleting this sObject.</b></div>") content.add("<br/>"*2) else: # changed the heading to say no dependencies content.add("The item to be deleted has no dependencies.<br/>", 'heading') content.add("There are %s items to be deleted" % len(my.search_keys)) content.add("<br/>"*2) content.add("Do you wish to continue deleting?") content.add("<br/>"*2) button_div = DivWdg() button_div.add_styles('width: 300px; height: 50px') button = ActionButtonWdg(title="Delete") button_div.add(button) content.add(button_div) button.add_style("float: left") button.add_behavior( { 'type': 'click_up', 'search_keys': my.search_keys, 'cbjs_action': ''' spt.app_busy.show("Deleting"); var top = bvr.src_el.getParent(".spt_delete_top"); var values = spt.api.Utility.get_input_values(top); var class_name = "tactic.ui.tools.DeleteCmd"; var kwargs = { 'search_keys': bvr.search_keys, 'values': values }; var server = TacticServerStub.get(); try { server.start({'title': 'Delete sObject', 'description': 'Delete sObject [' + bvr.search_keys + ']'}); server.execute_cmd(class_name, kwargs); server.finish(); // run the post delete and destroy the popup var popup = bvr.src_el.getParent(".spt_popup"); if (popup.spt_on_post_delete) { popup.spt_on_post_delete(); } spt.popup.destroy(popup); } catch(e) { spt.alert(spt.exception.handler(e)); } spt.app_busy.hide(); ''' } ) button = ActionButtonWdg(title="Cancel") button.add_style("float: left") button_div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_popup"); top.destroy(); ''' } ) content.add("<br clear='all'/>") return top
def update_collection_keywords(self, mode, base_search_type, input): ''' When there is an entry being added or removed in the asset_in_asset table (ie. adding asset to collection, removing asset from collection, or deleting a collection), the "collection" data set in the keywords_data needs to be updated. ''' # this is only for collections types stype_obj = SearchType.get(base_search_type) if stype_obj.get_value('type') != 'collection': return asset_in_asset_sobject = input.get("sobject") asset_stypes = SearchType.get_related_types(base_search_type, direction="parent") if not asset_stypes: return asset_stype = asset_stypes[0] parent_code = asset_in_asset_sobject.get("parent_code") search_code = asset_in_asset_sobject.get("search_code") parent_sobject = Search.get_by_code(asset_stype, parent_code) child_sobject = Search.get_by_code(asset_stype, search_code) collection_keywords_dict = {} parent_collection_keywords_dict = {} # Existing "collection" keywords in child's keywords_data child_keywords_data = child_sobject.get_json_value("keywords_data", {}) if isinstance(child_keywords_data, basestring): raise TacticException( "Invalid data found in keywords_data for %s. Please notify site administrator to correct it." % child_sobject.get_code()) # check for old data structure with only keywords filled and initialize if necessary if not child_keywords_data: user_keywords = child_sobject.get_value('user_keywords') original_keywords = child_sobject.get_value('keywords') if original_keywords and not user_keywords: # initiatize keywords_data in this case child_keywords_data['user'] = original_keywords child_sobject.set_value('user_keywords', original_keywords) # Existing "collection" keywords in parent's keywords_data parent_keywords_data = parent_sobject.get_json_value( "keywords_data", {}) # keywords of parent parent_collection_keywords = parent_keywords_data.get('user') if 'collection' in child_keywords_data: collection_keywords_dict = child_keywords_data.get('collection') if 'collection' in parent_keywords_data: parent_collection_keywords_dict = parent_keywords_data.get( 'collection') if mode == "insert": # Add parent's user defined keywords if parent_collection_keywords: collection_keywords_dict[ parent_code] = parent_collection_keywords # Also append parent's "collection" keywords_data collection_keywords_dict.update(parent_collection_keywords_dict) # Find all children that has [search_code] in their collection's keys # and update child_codes = self.get_child_codes(search_code, asset_stype) if child_codes: child_nest_sobjects = Search.get_by_code( asset_stype, child_codes) for child_nest_sobject in child_nest_sobjects: child_nest_collection_keywords_data = child_nest_sobject.get_json_value( "keywords_data", {}) child_nest_collection_keywords = child_nest_collection_keywords_data[ 'collection'] child_nest_collection_keywords.update( collection_keywords_dict) child_nest_sobject.set_json_value( "keywords_data", child_nest_collection_keywords_data) child_nest_sobject.commit(triggers=False) self.set_searchable_keywords(child_nest_sobject) elif mode == "delete": child_codes = [] if parent_code in collection_keywords_dict: # Remove "collection" keywords_data from child with key matching parent_code del collection_keywords_dict[parent_code] # Also need to remove parent's "collection" keywords_data from child for key in parent_collection_keywords_dict.keys(): del collection_keywords_dict[key] child_codes = self.get_child_codes(search_code, asset_stype) if child_codes: child_nest_sobjects = Search.get_by_code( asset_stype, child_codes) for child_nest_sobject in child_nest_sobjects: child_nest_collection_keywords_data = child_nest_sobject.get_json_value( "keywords_data", {}) child_nest_collection_keywords = child_nest_collection_keywords_data[ 'collection'] if parent_code in child_nest_collection_keywords: del child_nest_collection_keywords[parent_code] child_nest_sobject.set_json_value( "keywords_data", child_nest_collection_keywords_data) child_nest_sobject.commit(triggers=False) self.set_searchable_keywords(child_nest_sobject) child_keywords_data['collection'] = collection_keywords_dict child_sobject.set_json_value("keywords_data", child_keywords_data) child_sobject.commit(triggers=False) self.set_searchable_keywords(child_sobject)
def get_display(self): top = self.top self.set_as_panel(top) top.add_class("spt_delete_top") top.add_color("background", "background") top.add_color("color", "color") top.add_border() top.add_style("width: 400px") top.add_border() search_key = self.kwargs.get("search_key") search_keys = self.kwargs.get("search_keys") if search_key: sobject = Search.get_by_search_key(search_key) sobjects = [sobject] search_keys = [search_key] elif search_keys: sobjects = Search.get_by_search_keys(search_keys) sobject = sobjects[0] if not sobjects or not sobject: msg = "%s not found" % search_key return msg search_type = sobject.get_base_search_type() if search_type in ['sthpw/project', 'sthpw/search_object']: msg = 'You cannot delete these items with this tool' return msg self.search_keys = search_keys title = DivWdg() top.add(title) icon = IconWdg("WARNING", IconWdg.WARNING) icon.add_style("float: left") title.add(icon) if len(self.search_keys) > 1: title.add("Delete %s Items" % len(self.search_keys)) else: title.add("Delete Item [%s]" % (sobject.get_code())) title.add_style("font-size: 20px") title.add_style("font-weight: bold") title.add_style("padding: 10px") title.add("<hr/>") content = DivWdg() top.add(content) content.add_style("margin: 5px 10px 20px 10px") content.add( "The item to be deleted has a number of dependencies as described below:<br/>", 'heading') # find all the relationships related_types = SearchType.get_related_types(search_type, direction='children') items_div = DivWdg() content.add(items_div) items_div.add_style("padding: 10px") valid_related_ctr = 0 for related_type in related_types: if related_type == "*": print("WARNING: related_type is *") continue if related_type == search_type: continue if related_type in ['sthpw/search_object', 'sthpw/search_type']: continue item_div = self.get_item_div(sobjects, related_type) if item_div: items_div.add(item_div) valid_related_ctr += 1 if valid_related_ctr > 0: #icon = IconWdg("Note", "BS_NOTE") #icon.add_style("float: left") #content.add( icon ) content.add( "<div><b>By selecting the above, the corresponding related items will be deleted as well.</b></div>" ) content.add("<br/>" * 2) else: # changed the heading to say no dependencies content.add("The item to be deleted has no dependencies.<br/>", 'heading') num_items = len(self.search_keys) if num_items == 1: verb = "is 1 item" else: verb = "are %s items" % num_items content.add("There %s to be deleted" % verb) content.add("<br/>" * 2) content.add("Do you wish to continue deleting?") content.add("<br/>" * 3) button_div = DivWdg() button_div.add_class("spt_buttons") content.add(button_div) button_div.add_style('text-align: center') button = ActionButtonWdg(title="Delete", width=100, color="danger") button_div.add(button) button.add_style("display: inline-block") deleting_div = DivWdg() content.add(deleting_div) deleting_div.add( "<img src='/context/icons/common/indicator_snake.gif'/>") deleting_div.add_class("spt_delete_msg") deleting_div.add(" Deleting ...") deleting_div.add_style("text-align: center") deleting_div.add_style("font-size: 16px") deleting_div.add_style("margin: 20px") deleting_div.add_style("display: none") on_complete = self.kwargs.get("on_complete") button.add_behavior({ 'type': 'click_up', 'search_keys': self.search_keys, 'on_complete': on_complete, 'cbjs_action': ''' spt.app_busy.show("Deleting"); //spt.notify.show_message("Deleting ..."); //var button_el = bvr.src_el.getParent(".spt_buttons"); //button_el.setStyle("display", "none"); var top = bvr.src_el.getParent(".spt_delete_top"); var values = spt.api.Utility.get_input_values(top); var class_name = "tactic.ui.tools.DeleteCmd"; var kwargs = { 'search_keys': bvr.search_keys, 'values': values }; var del_trigger = function() { // for fast table var tmps = spt.split_search_key(bvr.search_keys[0]) var tmps2 = tmps[0].split('?'); var del_st_event = "delete|" + tmps2[0]; var bvr_fire = {}; var input = {'search_keys': bvr.search_keys}; bvr_fire.options = input; spt.named_events.fire_event(del_st_event, bvr_fire); } var server = TacticServerStub.get(); server.execute_cmd(class_name, kwargs, null, { on_complete: function() { //spt.notify.show_message("Finshed deleting ..."); // run the post delete and destroy the popup var popup = bvr.src_el.getParent(".spt_popup"); if (popup.spt_on_post_delete) { popup.spt_on_post_delete(); } del_trigger(); spt.popup.destroy(popup); if (bvr.on_complete) { on_complete = function() { eval(bvr.on_complete); } on_complete(); } spt.app_busy.hide(); }, on_error: function(e) { spt.notify.show_message("Error on delete"); spt.alert(spt.exception.handler(e)); spt.app_busy.hide(); } } ); ''' }) button = ActionButtonWdg(title="Cancel", width=100) button_div.add(button) button.add_style("display: inline-block") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_popup"); top.destroy(); ''' }) content.add("<br clear='all'/>") return top