Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Integer Edit-mode Component #397

Open
wants to merge 1 commit into
base: hotfix
Choose a base branch
from

Conversation

mpuyosa91
Copy link
Contributor

@mpuyosa91 mpuyosa91 commented Nov 16, 2023

When an integer field is modified, you can write non-numeric characters on it, this should not happen.

Description

  • ESLint fixes on modified files.
  • core/app/core/src/lib/fields/int/templates/edit/*: New Int component in edit view.
  • core/app/core/src/lib/fields/base-fields.manifest.ts[110~111,120, 164, 214]: Int component registration down 'int.edit' label
  • core/app/core/src/lib/core.ts:364 Export created classes

Motivation and Context

In an integer-type field, you should not be able to write non-decimal characters.

How To Test This

  1. Create all files in the Test Environment
  2. Rebuild the whole project, Quick Repair & Rebuild, executing database scripts if needed.
  3. Go to any or Create a new Contact, but open in Edit Mode
  4. Check the INT FIELD field, modify it with any value, and try to add a non-decimal character; save.
  5. Open the same record in edit mode, and repeat step 4.

Test Environment

public/legacy/custom/Extension/modules/Contacts/Ext/Vardefs/int_field.php

<?php
/**
 * @author SalesAgility <info@salesagility.com>.
 */

$dictionary['Contact']['fields']['int_field'] = [
    'name' => 'int_field',
    'vname' => 'LBL_INT_FIELD',
    'type' => 'int',
    'len' => 4,
    'required' => false,
    'audited' => true,
    'reportable' => true,
    'importable' => true,
    'unified_search' => true,
    'inline_edit' => true,
    'metadata' => [
        'min' => -4,
        'step' => 2,
        'max' => 10,
    ],
];

public/legacy/custom/Extension/modules/Contacts/Ext/Language/en_us.int_field.php

<?php
/**
 * @author SalesAgility <info@salesagility.com>.
 */

$mod_strings['LBL_INT_FIELD'] = 'Int Field';

public/legacy/custom/modules/Contacts/metadata/detailviewdefs.php

<?php
/**
 * @author SalesAgility <info@salesagility.com>.
 */

$viewdefs["Contacts"] = [
    "DetailView" => [
        "templateMeta" => [
            "form" => [
                "buttons" => [
                    "SEND_CONFIRM_OPT_IN_EMAIL" => EmailAddress::getSendConfirmOptInEmailActionLinkDefs(
                        "Contacts"
                    ),
                    0 => "EDIT",
                    1 => "DUPLICATE",
                    2 => "DELETE",
                    3 => "FIND_DUPLICATES",
                    4 => [
                        "customCode" =>
                            '<input type="submit" class="button" title="{$APP.LBL_MANAGE_SUBSCRIPTIONS}" onclick="this.form.return_module.value=\'Contacts\'; this.form.return_action.value=\'DetailView\'; this.form.return_id.value=\'{$fields.id.value}\'; this.form.action.value=\'Subscriptions\'; this.form.module.value=\'Campaigns\'; this.form.module_tab.value=\'Contacts\';" name="Manage Subscriptions" value="{$APP.LBL_MANAGE_SUBSCRIPTIONS}"/>',
                        "sugar_html" => [
                            "type" => "submit",
                            "value" => '{$APP.LBL_MANAGE_SUBSCRIPTIONS}',
                            "htmlOptions" => [
                                "class" => "button",
                                "id" => "manage_subscriptions_button",
                                "title" => '{$APP.LBL_MANAGE_SUBSCRIPTIONS}',
                                "onclick" =>
                                    'this.form.return_module.value=\'Contacts\'; this.form.return_action.value=\'DetailView\'; this.form.return_id.value=\'{$fields.id.value}\'; this.form.action.value=\'Subscriptions\'; this.form.module.value=\'Campaigns\'; this.form.module_tab.value=\'Contacts\';',
                                "name" => "Manage Subscriptions",
                            ],
                        ],
                    ],
                    "AOS_GENLET" => [
                        "customCode" =>
                            '<input type="button" class="button" onClick="showPopup();" value="{$APP.LBL_PRINT_AS_PDF}">',
                    ],
                    "AOP_CREATE" => [
                        "customCode" =>
                            '{if !$fields.joomla_account_id.value && $AOP_PORTAL_ENABLED}<input type="submit" class="button" onClick="this.form.action.value=\'createPortalUser\';" value="{$MOD.LBL_CREATE_PORTAL_USER}"> {/if}',
                        "sugar_html" => [
                            "type" => "submit",
                            "value" => '{$MOD.LBL_CREATE_PORTAL_USER}',
                            "htmlOptions" => [
                                "title" => '{$MOD.LBL_CREATE_PORTAL_USER}',
                                "class" => "button",
                                "onclick" =>
                                    'this.form.action.value=\'createPortalUser\';',
                                "name" => "buttonCreatePortalUser",
                                "id" => "createPortalUser_button",
                            ],
                            "template" =>
                                '{if !$fields.joomla_account_id.value && $AOP_PORTAL_ENABLED}[CONTENT]{/if}',
                        ],
                    ],
                    "AOP_DISABLE" => [
                        "customCode" =>
                            '{if $fields.joomla_account_id.value && !$fields.portal_account_disabled.value && $AOP_PORTAL_ENABLED}<input type="submit" class="button" onClick="this.form.action.value=\'disablePortalUser\';" value="{$MOD.LBL_DISABLE_PORTAL_USER}"> {/if}',
                        "sugar_html" => [
                            "type" => "submit",
                            "value" => '{$MOD.LBL_DISABLE_PORTAL_USER}',
                            "htmlOptions" => [
                                "title" => '{$MOD.LBL_DISABLE_PORTAL_USER}',
                                "class" => "button",
                                "onclick" =>
                                    'this.form.action.value=\'disablePortalUser\';',
                                "name" => "buttonDisablePortalUser",
                                "id" => "disablePortalUser_button",
                            ],
                            "template" =>
                                '{if $fields.joomla_account_id.value && !$fields.portal_account_disabled.value && $AOP_PORTAL_ENABLED}[CONTENT]{/if}',
                        ],
                    ],
                    "AOP_ENABLE" => [
                        "customCode" =>
                            '{if $fields.joomla_account_id.value && $fields.portal_account_disabled.value && $AOP_PORTAL_ENABLED}<input type="submit" class="button" onClick="this.form.action.value=\'enablePortalUser\';" value="{$MOD.LBL_ENABLE_PORTAL_USER}"> {/if}',
                        "sugar_html" => [
                            "type" => "submit",
                            "value" => '{$MOD.LBL_ENABLE_PORTAL_USER}',
                            "htmlOptions" => [
                                "title" => '{$MOD.LBL_ENABLE_PORTAL_USER}',
                                "class" => "button",
                                "onclick" =>
                                    'this.form.action.value=\'enablePortalUser\';',
                                "name" => "buttonENablePortalUser",
                                "id" => "enablePortalUser_button",
                            ],
                            "template" =>
                                '{if $fields.joomla_account_id.value && $fields.portal_account_disabled.value && $AOP_PORTAL_ENABLED}[CONTENT]{/if}',
                        ],
                    ],
                ],
            ],
            "maxColumns" => "2",
            "widths" => [
                0 => [
                    "label" => "10",
                    "field" => "30",
                ],
                1 => [
                    "label" => "10",
                    "field" => "30",
                ],
            ],
            "includes" => [
                0 => [
                    "file" => "modules/Contacts/Contact.js",
                ],
            ],
            "useTabs" => true,
            "tabDefs" => [
                "LBL_CONTACT_INFORMATION" => [
                    "newTab" => true,
                    "panelDefault" => "expanded",
                ],
                "LBL_PANEL_ADVANCED" => [
                    "newTab" => true,
                    "panelDefault" => "expanded",
                ],
                "LBL_PANEL_ASSIGNMENT" => [
                    "newTab" => true,
                    "panelDefault" => "expanded",
                ],
            ],
        ],
        "summaryTemplates" => [
            "edit" => "LBL_SUMMARY_PERSON",
            "detail" => "LBL_SUMMARY_PERSON",
        ],
        "topWidget" => [
            "type" => "statistics",
            "options" => [
                "statistics" => [
                    [
                        "labelKey" => "",
                        "type" => "contact-last-touchpoint",
                        "hideValueIfEmpty" => true,
                    ],
                ],
            ],
            "acls" => [
                "Contacts" => ["view", "list"],
            ],
        ],
        "sidebarWidgets" => [
            [
                "type" => "history-timeline",
                "acls" => [
                    "Contacts" => ["view", "list"],
                ],
            ],
        ],
        "recordActions" => [
            "actions" => [
                "print-as-pdf" => [
                    "key" => "print-as-pdf",
                    "labelKey" => "LBL_PRINT_AS_PDF",
                    "asyncProcess" => true,
                    "modes" => ["detail"],
                    "acl" => ["view"],
                    "aclModule" => "AOS_PDF_Templates",
                    "params" => [
                        "selectModal" => [
                            "module" => "AOS_PDF_Templates",
                        ],
                    ],
                ],
            ],
        ],
        "panels" => [
            "lbl_contact_information" => [
                0 => [
                    0 => [
                        "name" => "full_name",
                        "label" => "LBL_NAME",
                    ],
                    1 => "",
                ],
                1 => [
                    0 => [
                        "name" => "phone_work",
                        "label" => "LBL_OFFICE_PHONE",
                    ],
                    1 => [
                        "name" => "phone_mobile",
                        "label" => "LBL_MOBILE_PHONE",
                    ],
                ],
                2 => [
                    0 => [
                        "name" => "title",
                        "comment" => "The title of the contact",
                        "label" => "LBL_TITLE",
                    ],
                    1 => [
                        "name" => "department",
                        "label" => "LBL_DEPARTMENT",
                    ],
                ],
                3 => [
                    0 => [
                        "name" => "account_name",
                        "label" => "LBL_ACCOUNT_NAME",
                    ],
                    1 => [
                        "name" => "phone_fax",
                        "label" => "LBL_FAX_PHONE",
                    ],
                ],
                4 => [
                    0 => [
                        "name" => "email1",
                        "studio" => "false",
                        "label" => "LBL_EMAIL_ADDRESS",
                    ],
                    1 => 'int_field'
                ],
                5 => [
                    0 => [
                        "name" => "primary_address_street",
                        "label" => "LBL_PRIMARY_ADDRESS",
                        "type" => "address",
                        "displayParams" => [
                            "key" => "primary",
                        ],
                    ],
                    1 => [
                        "name" => "alt_address_street",
                        "label" => "LBL_ALTERNATE_ADDRESS",
                        "type" => "address",
                        "displayParams" => [
                            "key" => "alt",
                        ],
                    ],
                ],
                6 => [
                    0 => [
                        "name" => "description",
                        "comment" => "Full text of the note",
                        "label" => "LBL_DESCRIPTION",
                    ],
                    1 => "",
                ],
                7 => [
                    0 => [
                        "name" => "assigned_user_name",
                        "label" => "LBL_ASSIGNED_TO_NAME",
                    ],
                ],
            ],
            "LBL_PANEL_ADVANCED" => [
                0 => [
                    0 => [
                        "name" => "lead_source",
                        "comment" => "How did the contact come about",
                        "label" => "LBL_LEAD_SOURCE",
                    ],
                ],
                1 => [
                    0 => [
                        "name" => "report_to_name",
                        "label" => "LBL_REPORTS_TO",
                    ],
                    1 => [
                        "name" => "campaign_name",
                        "label" => "LBL_CAMPAIGN",
                    ],
                ],
            ],
            "LBL_PANEL_ASSIGNMENT" => [
                0 => [
                    0 => [
                        "name" => "date_entered",
                        "customCode" =>
                            '{$fields.date_entered.value} {$APP.LBL_BY} {$fields.created_by_name.value}',
                        "label" => "LBL_DATE_ENTERED",
                    ],
                    1 => [
                        "name" => "date_modified",
                        "customCode" =>
                            '{$fields.date_modified.value} {$APP.LBL_BY} {$fields.modified_by_name.value}',
                        "label" => "LBL_DATE_MODIFIED",
                    ],
                ],
            ],
        ],
    ],
];

public/legacy/custom/modules/Contacts/metadata/editviewdefs.php

<?php
/**
 * @author SalesAgility <info@salesagility.com>.
 */

$viewdefs["Contacts"] = [
    "EditView" => [
        "templateMeta" => [
            "form" => [
                "hidden" => [
                    0 => '<input type="hidden" name="opportunity_id" value="{$smarty.request.opportunity_id}">',
                    1 => '<input type="hidden" name="case_id" value="{$smarty.request.case_id}">',
                    2 => '<input type="hidden" name="bug_id" value="{$smarty.request.bug_id}">',
                    3 => '<input type="hidden" name="email_id" value="{$smarty.request.email_id}">',
                    4 => '<input type="hidden" name="inbound_email_id" value="{$smarty.request.inbound_email_id}">',
                ],
            ],
            "maxColumns" => "2",
            "widths" => [
                0 => [
                    "label" => "10",
                    "field" => "30",
                ],
                1 => [
                    "label" => "10",
                    "field" => "30",
                ],
            ],
            "useTabs" => false,
            "tabDefs" => [
                "LBL_CONTACT_INFORMATION" => [
                    "newTab" => false,
                    "panelDefault" => "expanded",
                ],
                "LBL_PANEL_ADVANCED" => [
                    "newTab" => false,
                    "panelDefault" => "expanded",
                ],
            ],
        ],
        "panels" => [
            "lbl_contact_information" => [
                0 => [
                    0 => [
                        "name" => "first_name",
                        "customCode" =>
                            '{html_options name="salutation" id="salutation" options=$fields.salutation.options selected=$fields.salutation.value}&nbsp;<input name="first_name"  id="first_name" size="25" maxlength="25" type="text" value="{$fields.first_name.value}">',
                    ],
                    1 => [
                        "name" => "last_name",
                    ],
                ],
                1 => [
                    0 => [
                        "name" => "phone_work",
                        "comment" => "Work phone number of the contact",
                        "label" => "LBL_OFFICE_PHONE",
                    ],
                    1 => [
                        "name" => "phone_mobile",
                        "comment" => "Mobile phone number of the contact",
                        "label" => "LBL_MOBILE_PHONE",
                    ],
                ],
                2 => [
                    0 => [
                        "name" => "title",
                        "comment" => "The title of the contact",
                        "label" => "LBL_TITLE",
                    ],
                    1 => "department",
                ],
                3 => [
                    0 => [
                        "name" => "account_name",
                        "displayParams" => [
                            "key" => "billing",
                            "copy" => "primary",
                            "billingKey" => "primary",
                            "additionalFields" => [
                                "phone_office" => "phone_work",
                            ],
                        ],
                    ],
                    1 => [
                        "name" => "phone_fax",
                        "comment" => "Contact fax number",
                        "label" => "LBL_FAX_PHONE",
                    ],
                ],
                4 => [
                    0 => [
                        "name" => "email1",
                        "studio" => "false",
                        "label" => "LBL_EMAIL_ADDRESS",
                    ],
                    1 => 'int_field'
                ],
                5 => [
                    0 => [
                        "name" => "primary_address_street",
                        "hideLabel" => true,
                        "type" => "address",
                        "displayParams" => [
                            "key" => "primary",
                            "rows" => 2,
                            "cols" => 30,
                            "maxlength" => 150,
                        ],
                    ],
                    1 => [
                        "name" => "alt_address_street",
                        "hideLabel" => true,
                        "type" => "address",
                        "displayParams" => [
                            "key" => "alt",
                            "copy" => "primary",
                            "rows" => 2,
                            "cols" => 30,
                            "maxlength" => 150,
                        ],
                    ],
                ],
                6 => [
                    0 => [
                        "name" => "description",
                        "label" => "LBL_DESCRIPTION",
                    ],
                    1 => "",
                ],
                7 => [
                    0 => [
                        "name" => "assigned_user_name",
                        "label" => "LBL_ASSIGNED_TO_NAME",
                    ],
                ],
            ],
            "LBL_PANEL_ADVANCED" => [
                0 => [
                    0 => [
                        "name" => "lead_source",
                        "comment" => "How did the contact come about",
                        "label" => "LBL_LEAD_SOURCE",
                    ],
                ],
                1 => [
                    0 => [
                        "name" => "report_to_name",
                        "label" => "LBL_REPORTS_TO",
                    ],
                    1 => "campaign_name",
                ],
            ],
        ],
    ],
];

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Final checklist

  • My code follows the code style of this project found here.
  • My change requires a change to the documentation.
  • I have read the How to Contribute guidelines.

@clemente-raposo
Copy link
Contributor

Hi @mpuyosa91 we should add the PR or issue number to the commits

@clemente-raposo clemente-raposo added Status:Requires Updates Issues & PRs which requires input or update from the author Status: Requires Code Review labels Dec 6, 2023
@mpuyosa91 mpuyosa91 changed the title Add Integer Edit-mode Component Closes #397 Add Integer Edit-mode Component Dec 6, 2023
@mpuyosa91 mpuyosa91 changed the title Closes #397 Add Integer Edit-mode Component Closes #397 - Add Integer Edit-mode Component Dec 6, 2023
mpuyosa91 added a commit to mpuyosa91/SuiteCRM-Core that referenced this pull request Dec 6, 2023
@mpuyosa91 mpuyosa91 force-pushed the feature/add_integer_edit_mode_component branch from 01c4b24 to 2174e9b Compare December 6, 2023 13:22
@mpuyosa91 mpuyosa91 changed the title Closes #397 - Add Integer Edit-mode Component Add Integer Edit-mode Component Dec 6, 2023
@mpuyosa91 mpuyosa91 force-pushed the feature/add_integer_edit_mode_component branch from 2174e9b to f6235ad Compare December 7, 2023 13:10
@mpuyosa91 mpuyosa91 added Status: Fix Proposed A issue that has a PR related to it that provides a possible resolution and removed Status:Requires Updates Issues & PRs which requires input or update from the author labels Dec 7, 2023
@clemente-raposo clemente-raposo added Status:Assessed PRs that have been tested and confirmed to resolve an issue by a core team member Status: Requires Testing Status: Passed Code Review and removed Status: Requires Code Review Status: Fix Proposed A issue that has a PR related to it that provides a possible resolution labels Dec 7, 2023
@johnM2401 johnM2401 added Status:Requires Updates Issues & PRs which requires input or update from the author and removed Status: Requires Testing labels Feb 27, 2024
@johnM2401
Copy link

Hey @mpuyosa91 !

I've given this a round of testing, and I've noticed some odd and inconsistent behaviour.

See gif:
textInt

First test:
I first enter "12345a"
Entering the text character "a" seems to clear out the whole field.

I then re-enter "12345a"
However, entering "a" the second time does not clear out the whole field.

Pressing save then seems to save the value "1234", (missing the 5)


Second test:
Then, I enter "12345a"
As its the first time typing a text character, it clears out the whole field

I then enter "5555555"
After saving, it seems to revert back to "1234", ignoring the "5555555"


Is this behaviour expected?
It feels as though it should strip out the characters on-save, and not completely clear the field when entering a non-number character
Is that right?



Additionally, it seems to be clearing out the contents of the integer field when I enter in " , " or " . " or " ' "
(Which are common decimal and thousands seperators)
Should these characters be exempt?

What are your thoughts?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status:Assessed PRs that have been tested and confirmed to resolve an issue by a core team member Status: Passed Code Review Status: Requires Testing Status:Requires Updates Issues & PRs which requires input or update from the author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants