Skip to main content

Hi Team,

We have a page where we have rendering the Edit button once the case status is claimed, This Edit button is using toggle Save cancel script. once status is in pending status we have two section displayed and once status is set to claimed, we are displaying 2 more sections. 

now our requirement is we want to display this edit button before the claimed Status so user who had created the request would be able to edit the original request. But since in exisitng code we are passing 4 section ID in the code, we are unable to use the edit feature.

below is the code : - 

// Set the selector for which components to toggle. For example, to toggle// specific named components, set the selector to://   #ComponentUniqueID1, #AnotherComponent, #AThirdComponent
// Or, to toggle all field editors and tables, use this selector:
//   .nx-basicfieldeditor:visible, .nx-skootable
var ComponentSelector   = ‘#Test1, #AnotherComponent, #AThirdComponent,#test1,#tabID’;
var $ = skuid.$;
var myModel = argumentsa0].model;


$(‘#cancelb’).addClass(‘btnHide’);
// determine what mode was are moving into
var button = argumentsu0].button;
var startEdit = false;
var isEditButton = false;
if (button.hasClass(‘btnEdit’)) {
    startEdit = !button.hasClass(‘btnEditActive’);
    isEditButton = true;
} else if (button.hasClass(‘btnEditCancel’)) {
    startEdit = false;
} else {
    console.log(‘Unknown button in editModeController; missing class btnEdit or btnEditCancel’);
    return;
}
// Iterate over the selected components and switch them to the new mode, then
// force a re-render.
var componentElems = $( ComponentSelector );
$.each( componentElems, function( index, componentElem ){
    //console.log(‘Processing component’);
    //console.log(componentElem);
    var component = $( componentElem ).data( ‘component’ );
    //console.log(component);
    
    // Currently, this snippet only supports toggling tables and field editors
    // However, it would be relatively easy to add other types of components
    // as appropriate by adding a “case” statement below:
    switch ( component.getType() ){
        case ‘skootable’:
        case ‘basicfieldeditor’:
            var componentObject = $( componentElem ).data( ‘object’ );
            //console.log(componentObject);
            componentObject.mode = componentObject.list.mode = (startEdit ? ‘edit’ : ‘readonly’);
            componentObject.list.render({doNotCache:true});
            break;
    }
});
// update buttons and model based on what happened
if (startEdit) {
    // track that we have entered edit mode
    $(‘.btnEdit’).addClass(‘btnEditActive’);
    // unhide cancel
    $(‘#btnCancelEdit’).removeClass(‘btnHide’);
    
     //$(‘#cancelb’).hide();
  // adjust edit to correct text and icon
    $(‘.btnEdit’).find(‘.ui-button-text’).text(‘Save’);
   $(‘.btnEdit’).find(‘.ui-icon’).removeClass(‘sk-icon-edit’).addClass(‘sk-icon-save’);
    
}
else {
    // track that we have left edit mode
    $(‘.btnEdit’).removeClass(‘btnEditActive’);
    // hide cancel button
    $(‘#btnCancelEdit’).addClass(‘btnHide’);
    
    //$(‘#cancelb’).show();
    // adjust edit to correct text and icon
    $(‘.btnEdit’).find(‘.ui-button-text’).text(‘Edit’);
    $(‘.btnEdit’).find(‘.ui-icon’).removeClass(‘sk-icon-save’).addClass(‘sk-icon-edit’);
    // note that normally you would update the model that is associated with this button, with this line:
     //var myModel = arguments0].model;
    // however, in this case, our model is coming from a page include, so we need more
    // direct reference to the model
    
    if (isEditButton) {
        myModel.save({callback: function(result){
            if (result.totalsuccess) {
            myModel.updateData();
            var $ = skuid.$;
// To start showing the message
        $.blockUI({
            message: ‘Please Wait… Your Record is Getting Saved’
        });
            setTimeout(function(){
    // Turn off the block UI
         $.unblockUI();
        },4000);
        }}});
    } 
    else 
        myModel.cancel();
       
    

}
 $(‘#cancelb’).removeClass(‘btnHide’);

Please suggest…

Be the first to reply!

Reply