server/gokbg3/grails-app/assets/javascripts/gokb/action-forms.js
/**
     * Method that updates the available actions on a the action list
     */
Method that updates the available actions on a the action list
Method that updates the available actions on a the action list
function updateAvailableActions() {
      var allActionsAvailable = [];
      $('input.obj-action-ck-box:checked').each(function(i) {
        var elem = $(this);
        if (i == 0) {
          var json = elem.attr('data-actns');
          allActionsAvailable = $.parseJSON(json);
        } else {
          var json = elem.attr('data-actns');
          var elementActions = $.parseJSON(json);
          allActionsAvailable = $.grep(allActionsAvailable, function(action, index) {
            var match = $.grep(elementActions, function (el, i) {
              return el.code == action.code && el.label == action.label;
            });
            return match.length > 0
          });
        }
      });
      var actionsList = $('ul.actions')
      actionsList.empty()
      if (allActionsAvailable.length > 0) {
        $.each(allActionsAvailable, function (index, action) {
           var link = $("<a>", { bulkaction:action.code,text:action.label,class:"selectedAction", href: "#"  });
           var listItem = $("<li>").append(link);
           actionsList.append(listItem);
        });
      } else {
        setActionListEmpty();
      }
    }
function updateAvailableActions ( ) { var allActionsAvailable = [ ] ; $ ( 'input.obj-action-ck-box:checked' ) . each ( function ( i ) { var elem = $ ( this ) ; if ( i == 0 ) { var json = elem . attr ( 'data-actns' ) ; allActionsAvailable = $ . parseJSON ( json ) ; } else { var json = elem . attr ( 'data-actns' ) ; var elementActions = $ . parseJSON ( json ) ; allActionsAvailable = $ . grep ( allActionsAvailable , function ( action , index ) { var match = $ . grep ( elementActions , function ( el , i ) { return el . code == action . code && el . label == action . label ; } ) ; return match . length > 0 } ) ; } } ) ; var actionsList = $ ( 'ul.actions' ) actionsList . empty ( ) if ( allActionsAvailable . length > 0 ) { $ . each ( allActionsAvailable , function ( index , action ) { var link = $ ( "<a>" , { bulkaction : action . code , text : action . label , class : "selectedAction" , href : "#" } ) ; var listItem = $ ( "<li>" ) . append ( link ) ; actionsList . append ( listItem ) ; } ) ; } else { setActionListEmpty ( ) ; } }
Method that updates the available actions on a the action list
Method that updates the available actions on a the action list
// alert("update actions"); // Step through each checked box. // Set all actions available to this objects actions. // Filter the array using a callback that checks that this element actions contains // the object. // Add the available actions to the list of actions // Disable/enable the form elements depending on the actions available // Add the options to the list. // No actions available disable controls.