CRM Open Source Business & Social CRM Software

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: HOWTO - Enhance ModuleBuilder generated modules to include AJAX

  1. #1
    kenneth.thorman is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    191

    Default HOWTO - Enhance Module Builder generated modules

    This little post describes how to enhance modules generated via the module builder so that the modules can offer functionality like, some of these features have been included in the 5.0 GA/Release version of SugarCrm. There are still a few things described here that needs manual tweaking.

    Ajax Inline QuickCreate
    SideQuickCreate (in Shortcut area)
    Custom fields
    Studio Support for drag and drop

    If you go to the "Cases" tab (or any of the other built in tabs) and try to create a Bug you will see that you will creating the bug using AJAX, json (i.e no page reload).
    You can also see that when clicking on the Cases tab there is a side quick create option ( on the left side in the screen shot attached).
    If you go to Admin/Studio you will see that you can modify already installed modules (and notice that Studio actually gives you more freedom than the Module Builder does currently)


    Download your zip file.
    Extract.

    MISSING SELECT LINK IN POPUP SEARCH:
    Missing or not using the name field and thus missing a way to select the specific data row in a popup select box?
    Modify the relevant module ZIP\SugarModule\modules\SOMEMODULE\metadata\listvi ewdefs.php

    'START_DATE' =>
    array (
    'width' => '10',
    'label' => 'LBL_START_DATE',
    'default' => true,
    'link' => true, // this is the one to set on the field you want to use as a link
    ),

    SHOW THIRD MODULE RELATED INFO IN A SUBPANEL:
    See post: HOWTO - Hack Sugar to support related module info in subpanel (one-many)


    HIDE A TAB BUT SHOW SUBPANEL:
    When you generate packages via the builtin module builder most of the modules in the package makes sense to show as main tabs, however some of the modules does not make sense to show as a main tab since you only use then in relation to another module which most likely allows access to the related data. Example, you build a CV database in Sugar. CV is main entry, a CV has some related data like skills, interests, education, work experience ...
    Skills will most likely have its own tab since this can be reused to enhance the project builtin SugarCrm module, but interests, education and work experience will most likely be unique to the specific CV. To avoid cluttering up the main tab menu we want to hide the interests, education and work experience tabs but we want to show them as subpanels.

    in the manifest.php locate

    'beans' =>
    array (
    0 =>
    array (
    'module' => 'inux_Skill',
    'class' => 'inux_Skill',
    'path' => 'modules/inux_Skill/inux_Skill.php',
    'tab' => true, // set this to false to hide the main tab
    ),

    then in the relevant modules where this hidden tab/modules is to be used as a subpanel you should add the following
    (most likely to be in the following locations (for CV))
    ZIP\SugarModules\layoutdefs\CV.php
    ZIP\SugarModules\modules\CV\metadata\subpaneldefs. php


    // Allow these modules to be shown in subpanels even if they do not have their own tab
    global $modules_exempt_from_availability_check;
    $modules_exempt_from_availability_check['Education'] = 'Education';
    $modules_exempt_from_availability_check['WorkExperience'] = 'WorkExperience';
    $modules_exempt_from_availability_check['Interests'] = 'Interests';

    (thank you for this information goes to Andopes for answering my question about this in this thread Hiding a tab but still showing the subpanels in related modules.)

    DROPDOWN LISTS USED IN THE MODULE ARE NOT EXPORTED
    You can find the definition in the /cache/jslanguage/en_us.js file. Search for the list name (this is on the sugar instance you used to generated the module and also created the dropdown list)

    This needs to be added to the following file in the zip.

    ZIP\SugarModules\language\application\en_us.lang.p hp

    Example:
    (/cache/jslanguage/en_us.js )
    "status_list":{"Draft":"Draft","Inprogress":"Inpro gress","Done":"Done","Review":"Review","Finished": "Finished"}

    put the following in ZIP\SugarModules\language\application\en_us.lang.p hp

    $GLOBALS['app_list_strings']['status_list']=array (
    'Draft' => 'Draft',
    'Inprogress' => 'Inprogress',
    'Done' => 'Done',
    'Review' => 'Review',
    'Finished' => 'Finished',
    );




    STUDIO SUPPORT:

    To enable studio support in a module please add a file named studio.php to the ZIP/SugarModules/modules/MODULENAME/metadata folder (see attachment for studio.php)


    SUBPANEL AJAX SUPPORT:
    To add AJAX support we need to go to ZIP/SugarModules/layoutdefs/MYMODULE.php and add this to the end of the array found in that file). You need to decide on which of the buttons you would like to keep.

    // You need to define this if you would like AJAX func builtin in the generated module
    'top_buttons' => array(

    // Quick create button, you need to have a MODULENAMEQuickCreate.php file in the ZIP/SugarModules/modules/MODULENAME/ directory
    array('widget_class' => 'SubPanelTopButtonQuickCreate'),

    // Simple select
    array('widget_class' => 'SubPanelTopSelectButton'),

    // Advanced multiselect functionality in the select popup form
    array(
    'widget_class' => 'SubPanelTopSelectButton', // select button
    'popup_module' => 'test_master', // just enter the same module as the current module here, is no related module
    'mode' => 'MultiSelect', // multi select
    'initial_filter_fields' => array(), // here you can prefilter the data before it even starts to look at relations ships between parent /child
    ),
    ),


    Create a file in ZIP/SugarModules/modules/MYMODULE/MYMODULEQuickCreate.php (you can use the one in the attachment)
    Search and replace in this file "MODULE_NAME" with the actual full module name.

    You can see the available widgets included in Sugar here SugarCE/include/generic/SugarWidgets. Please note that it is not all widgets that makes sense to use here.


    STUDIO SUBPANEL SUPPORT:
    When you are done, copy ZIP/SugarModules/layoutdefs/MYMODULE.php to the metadata folder and rename it to subpaneldefs.php (this allows you to drag-n-drop-change the subpanel definitions from within studio)


    SIDEQUICKCREATE
    1. Add a label definition in the ZIP/SugarModules/modules/MYMODULE/language/LANGUAGE_NAME.lang.php named "LBL_NEW_FORM_TITLE"
    'LBL_NEW_FORM_TITLE' => 'New MYMODULE',

    2. Quick Repair Sugar

    3. Copy the (accompaning) sidecreateviewdefs.php to ZIP/modules/<MODULENAME>/metadata/sidecreateviewdefs.php
    and modify it to show and edit the fields required. A good way to figure out how to add/remove fields from
    these arrays is to either copy something from the built in modules, or use studio to generate the quickcreatedefs.php for the module.
    Then Save and deploy. Go to SugarINSTALL/custom/modules/MYMODULE/metadata/quickcreatedefs.php and copy paste the "panels" array to the
    ZIP/modules/<MODULENAME>/metadata/sidecreateviewdefs.php. Please remeber to on use one column and not make it too wide if using studio.

    Also remeber to remove the generated file from SugarINSTALL/custom/modules/MYMODULE/metadata/quickcreatedefs.php
    For some reason quickcreatedefs.php is causing a bug in the system so make sure you remove that file ([see the filed bug here )



    MODIFYING SUBPANELS:
    There is one thing missing, the attends school checkbox does not come up as planned in the child subpanel (when viewing related children from a parent)

    Uninstall the generated module from Module Builder using Admin/Module Loader
    Zip up the files in a zip file and make sure manifest.php is in the root of this zip
    Install the module using Admin/Module Loader
    This can be fixed in 2 ways edit the module in Studio (You might have to do a Admin/Repair: Quick Repair and possibly Repair Relationships before this will work) and drag and drop the subpanel
    (please note that all the changes you are doing here will result in a file being created by studio at the following location SUGARINSTALL/custom/modules/MODULENAME/metadata)

    or do it manually by copying the file (normally this would be default.php) located at SUGARINSTALL/modules/MODULENAME/metadata/subpanels to SUGARINSTALL/custom/modules/MODULENAME/metadata and add or change the existing value for
    attends_school to look like the change it to look


    'MY_CHECKBOX_FIELD'=>array(
    'vname' => 'LBL_MY_CHECKBOX_FIELD',
    'width' => '5%',
    'widget_class' => 'Fieldbool',
    ),



    REMEMBER THAT THE WIDGET CLASS IS CASE SENSITIVE ON LINUX SYSTEMS SO TO AVOID PROBLEMS KEEP THE CASING EXACT.

    SUMMARY
    It seems like the defs files are using almost the same syntax or maybe even exactly the same syntax.
    So if you are not into handediting files use the Studio support to create, modify, order things and the copy paste the def
    to the appropriate file.


    USE THIS AT YOUR OWN RISC
    Attached Files Attached Files
    Last edited by kenneth.thorman; 2008-12-02 at 12:15 PM. Reason: This is a little thread used a my personal reminder of how to do things

  2. #2
    kenneth.thorman is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    191

    Default Re: HOWTO - Enhance ModuleBuilder generated modules to include AJAX

    Updated post #1 with

    DROPDOWN LISTS USED IN THE MODULE ARE NOT EXPORTED
    You can find the definition in the /cache/jslanguage/en_us.js file. Search for the list name (this is on the sugar instance you used to generated the module and also created the dropdown list)

    This needs to be added to the following file in the zip.

    ZIP\SugarModules\language\application\en_us.lang.p hp

    Example:
    (/cache/jslanguage/en_us.js )
    "status_list":{"Draft":"Draft","Inprogress":"Inpro gress","Done":"Done","Review":"Review","Finished": "Finished"}

    put the following in ZIP\SugarModules\language\application\en_us.lang.p hp

    $GLOBALS['app_list_strings']['status_list']=array (
    'Draft' => 'Draft',
    'Inprogress' => 'Inprogress',
    'Done' => 'Done',
    'Review' => 'Review',
    'Finished' => 'Finished',
    );


    The files needed to move the module generated dropdowns to another sugar installation are all located under
    custom/include/language
    and
    custom/modulebuilder/packages
    Last edited by kenneth.thorman; 2008-06-03 at 11:04 AM.

  3. #3
    kenneth.thorman is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    191

    Default Re: HOWTO - Enhance ModuleBuilder generated modules to include AJAX

    MISSING SELECT LINK IN POPUP SEARCH:
    Missing or not using the name field and thus missing a way to select the specific data row in a popup select box?
    Modify the relevant module ZIP\SugarModule\modules\SOMEMODULE\metadata\listvi ewdefs.php

    'START_DATE' =>
    array (
    'width' => '10',
    'label' => 'LBL_START_DATE',
    'default' => true,
    'link' => true, // this is the one to set on the field you want to use as a link
    ),

  4. #4
    kenneth.thorman is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    191

    Default Re: HOWTO - Enhance ModuleBuilder generated modules to include AJAX

    SIDECREATE SHORTCUT IN DETAILVIEW
    I have quite a few simple lookup like values defined by using custom modules. When I have to populate them there are only 1-3 fields to fill and so I use the sidecreate to create them since this seems faster. When I click save and Sugar switches to detailview the shortcut sidecreate disappears. I would like it to still be present and just blank ready to enter a new item.

    You have to modify the file themes/$current_theme/header.php line no 784. TODO: Should put this fix in a generic location that is theme independent.


    if ($currentModule && function_exists('get_new_record_form')) {
    $xtpl->assign("NEW_RECORD", get_new_record_form());
    $xtpl->parse("main.left_form_new_record");
    $new_record_form = true;
    }


    delete the code $action == "index" in if condition


    Thank you sanjeev1225 for providing this solution in this thread Sidecreate shortcut in detailview

  5. #5
    kenneth.thorman is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    191

    Default Re: HOWTO - Enhance ModuleBuilder generated modules to include AJAX

    CREATE NEW ROW IN SUBPANEL WITHOUT HIDDING EXISTING ROWS:

    Please see this post Subpanel: Create new AJAX without hidding existing rows

  6. #6
    Translation is offline Junior Member
    Join Date
    Feb 2008
    Posts
    3

    Default Re: HOWTO - Enhance ModuleBuilder generated modules to include AJAX

    So useful to me. I will transfer this to my beijing friends, They need this in chinese translation.

  7. #7
    MackenzieBall is offline Junior Member
    Join Date
    Oct 2008
    Posts
    1

    Default Re: HOWTO - Enhance ModuleBuilder generated modules to include AJAX

    it is so useful to me..thnks

  8. #8
    kenneth.thorman is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    191

    Default Re: HOWTO - Enhance ModuleBuilder generated modules to include AJAX

    HOWTO: Add support for SideCreateViewDefs in studio
    SideQuickCreate support added in Studio

    HOWTO: Add a Create security right in SugarCrm
    create users who can input data but cannot edit
    "Create new" - security right

    HOWTO: Create inner join/left join in advanced search
    Basic/Adv Search join/left join seaches

  9. #9
    topchinesetranslation is offline Junior Member
    Join Date
    Dec 2008
    Posts
    1

    Default Re: HOWTO - Enhance ModuleBuilder generated modules to include AJAX

    great information, my contacts in china will need it in Chinese translation

  10. #10
    coca12 is offline Junior Member
    Join Date
    Jan 2009
    Posts
    1

    Default Re: HOWTO - Enhance ModuleBuilder generated modules to include AJAX

    so useful..thnks

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •