Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-7266

Auto-complete on lookup field should be able to support filter by date.

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Implemented
    • Affects Version/s: Trunk
    • Fix Version/s: 16.11.01
    • Component/s: ALL COMPONENTS
    • Labels:
      None

      Description

      Hi,

      For the general reason, if the lookup popup (like as performFind service work) able to filter the result from date. so, in the auto complete for lookup filed should be also able too.

      Simple :

      add this tag in action tag before call LookupDecorator
      and filter on field "fromDate", "thruDate" as default.

          <set field="conditionDates.filterByDate" value="true"/>
      

      Advance :

      you can customize "fromDate" and "thruDate" field names by do follow below

          <set field="conditionDates.filterByDate" value="true"/>
          <set field="conditionDates.fromDateName" value="startDate"/>
          <set field="conditionDates.thruDateName" value="endDate"/>
      

      Best Regards,
      Kongrath

      1. OFBIZ-7266.patch
        3 kB
        Kongrath Suankaewmanee
      2. OFBIZ-7266-NMA.patch
        3 kB
        Nicolas Malin
      3. OFBIZ-7266-NMA.patch
        3 kB
        Nicolas Malin

        Activity

        Hide
        deepak.dixit Deepak Dixit added a comment -

        Hi Kongrath Suankaewmanee,

        We have support in autocompleter to pass andCondition from screen. You can use this to add filterByDate or any custom condition.

        <set field="andCondition" value="${groovy: return org.ofbiz.entity.condition.EntityCondition.makeCondition(&quot;isVirtual&quot;, &quot;Y&quot;)}"/>
        
        Show
        deepak.dixit Deepak Dixit added a comment - Hi Kongrath Suankaewmanee , We have support in autocompleter to pass andCondition from screen. You can use this to add filterByDate or any custom condition. <set field= "andCondition" value= "${groovy: return org.ofbiz.entity.condition.EntityCondition.makeCondition(&quot;isVirtual&quot;, &quot;Y&quot;)}" />
        Hide
        kongrath Kongrath Suankaewmanee added a comment -

        Hi Deepak Dixit,

        Thank you for your reply. Yes, you're right.

        But I think would it be better if we make it easy for developer to do a filter by date?

        Thank,
        Kongrath

        Show
        kongrath Kongrath Suankaewmanee added a comment - Hi Deepak Dixit, Thank you for your reply. Yes, you're right. But I think would it be better if we make it easy for developer to do a filter by date? Thank, Kongrath
        Hide
        soledad Nicolas Malin added a comment -

        Your proposal is fine.

        In detail I'mn't really fan to set all parameter on the context root. Why don't use a dedicate map like conditionDate as conditionFields ?

        Where you can set all your parameters related to your expression date like :

            <set field="conditionDates.filterByDate" value="true"/>
            <set field="conditionDates.fromDateName" value="startDate"/>
            <set field="conditionDates.thruDateName" value="endDate"/>
        

        after to resolve this, from my mind, when a nowTimestamp is present, we can't use the cache. I prefer use a post treatment to filter.
        I says that but on other point, the auto completion realize a findList without cache. I didn't see why we don'tu use the cache here.

        Show
        soledad Nicolas Malin added a comment - Your proposal is fine. In detail I'mn't really fan to set all parameter on the context root. Why don't use a dedicate map like conditionDate as conditionFields ? Where you can set all your parameters related to your expression date like : <set field= "conditionDates.filterByDate" value= " true " /> <set field= "conditionDates.fromDateName" value= "startDate" /> <set field= "conditionDates.thruDateName" value= "endDate" /> after to resolve this, from my mind, when a nowTimestamp is present, we can't use the cache. I prefer use a post treatment to filter. I says that but on other point, the auto completion realize a findList without cache. I didn't see why we don'tu use the cache here.
        Hide
        kongrath Kongrath Suankaewmanee added a comment -

        Hi Nicokas Malin,

        I'm agree with you about use a dedicate map to separate it out from context root parameter.

        But for use cache in findList, I'm not sure that's good or not. Because I ever use cache and fetch list after update field in entity the data that I fetch doesn't correct it show the old before update.

        Now, I try again seem it work...

        Show
        kongrath Kongrath Suankaewmanee added a comment - Hi Nicokas Malin , I'm agree with you about use a dedicate map to separate it out from context root parameter. But for use cache in findList, I'm not sure that's good or not. Because I ever use cache and fetch list after update field in entity the data that I fetch doesn't correct it show the old before update. Now, I try again seem it work...
        Hide
        deepak.dixit Deepak Dixit added a comment -

        Hi Kongrath Suankaewmanee,

        You can attach patch using same name, jira automatically handle version. You can use <TICEKT_ID>.patch for patch name

        Show
        deepak.dixit Deepak Dixit added a comment - Hi Kongrath Suankaewmanee , You can attach patch using same name, jira automatically handle version. You can use <TICEKT_ID>.patch for patch name
        Hide
        kongrath Kongrath Suankaewmanee added a comment -

        patch update for the current revision.

        Show
        kongrath Kongrath Suankaewmanee added a comment - patch update for the current revision.
        Hide
        kongrath Kongrath Suankaewmanee added a comment -

        Has anyone look at this a feature that's necessary for the OFBiz?

        That I expect it should be made a simple way to do a filter by date on auto-complete.

        Thank you.

        Show
        kongrath Kongrath Suankaewmanee added a comment - Has anyone look at this a feature that's necessary for the OFBiz? That I expect it should be made a simple way to do a filter by date on auto-complete. Thank you.
        Hide
        soledad Nicolas Malin added a comment -

        I will try to check it today

        Show
        soledad Nicolas Malin added a comment - I will try to check it today
        Hide
        kongrath Kongrath Suankaewmanee added a comment -

        Hi Nicolas Malin,

        Thank you for your quick reply.

        Show
        kongrath Kongrath Suankaewmanee added a comment - Hi Nicolas Malin , Thank you for your quick reply.
        Hide
        soledad Nicolas Malin added a comment -

        Kongrath I reviewed the patch and I realized some optimization but not tested yes . Do you have an example to implement this search to test ?

        Otherwise, I will prepare some data to do this.

        Show
        soledad Nicolas Malin added a comment - Kongrath I reviewed the patch and I realized some optimization but not tested yes . Do you have an example to implement this search to test ? Otherwise, I will prepare some data to do this.
        Hide
        kongrath Kongrath Suankaewmanee added a comment -

        You can test on the product. Go to product and select one product to edit and then set "Sales Discontinuation Through Date",

        and this code to LookupProduct in

        {OFBiz Path}

        /applications/product/widget/catalog/LookupScreens.xml :

            <set field="conditionDates.filterByDate" value="true"/>
            <set field="conditionDates.fromDateName" value="salesDiscontinuationDate"/>
            <set field="conditionDates.thruDateName" value="salesDiscontinuationDate"/>
        

        LookupProduct code will be look like this :

            <screen name="LookupProduct">
                <section>
                    <condition>
                        <if-service-permission service-name="catalogPermissionCheck" main-action="VIEW"/>
                    </condition>
                    <actions>
                        <property-map resource="ProductUiLabels" map-name="uiLabelMap" global="true"/>
                        <set field="title" value="${uiLabelMap.PageTitleLookupProduct}"/>
                        <set field="queryString" from-field="result.queryString"/>
                        <set field="entityName" value="Product"/>
                        <set field="searchFields" value="[productId, internalName, brandName]"/>
                        <set field="conditionDates.filterByDate" value="true"/>
                        <set field="conditionDates.fromDateName" value="salesDiscontinuationDate"/>
                        <set field="conditionDates.thruDateName" value="salesDiscontinuationDate"/>
                    </actions>
                    <widgets>
                        <decorator-screen name="LookupDecorator" location="component://common/widget/CommonScreens.xml">
                            <decorator-section name="search-options">
                                <include-form name="lookupProduct" location="component://product/widget/catalog/FieldLookupForms.xml"/>
                            </decorator-section>
                            <decorator-section name="search-results">
                                <include-form name="listLookupProduct" location="component://product/widget/catalog/FieldLookupForms.xml"/>
                            </decorator-section>
                        </decorator-screen>
                    </widgets>
                </section>
            </screen>
        

        then after you try to search product on lookup field, product should not show on auto-complete.

        Show
        kongrath Kongrath Suankaewmanee added a comment - You can test on the product. Go to product and select one product to edit and then set "Sales Discontinuation Through Date", and this code to LookupProduct in {OFBiz Path} /applications/product/widget/catalog/LookupScreens.xml : <set field= "conditionDates.filterByDate" value= "true" /> <set field= "conditionDates.fromDateName" value= "salesDiscontinuationDate" /> <set field= "conditionDates.thruDateName" value= "salesDiscontinuationDate" /> LookupProduct code will be look like this : <screen name= "LookupProduct" > <section> <condition> <if-service-permission service-name= "catalogPermissionCheck" main-action= "VIEW" /> </condition> <actions> <property-map resource= "ProductUiLabels" map-name= "uiLabelMap" global= "true" /> <set field= "title" value= "${uiLabelMap.PageTitleLookupProduct}" /> <set field= "queryString" from-field= "result.queryString" /> <set field= "entityName" value= "Product" /> <set field= "searchFields" value= "[productId, internalName, brandName]" /> <set field= "conditionDates.filterByDate" value= "true" /> <set field= "conditionDates.fromDateName" value= "salesDiscontinuationDate" /> <set field= "conditionDates.thruDateName" value= "salesDiscontinuationDate" /> </actions> <widgets> <decorator-screen name= "LookupDecorator" location= "component://common/widget/CommonScreens.xml" > <decorator-section name= "search-options" > <include-form name= "lookupProduct" location= "component://product/widget/catalog/FieldLookupForms.xml" /> </decorator-section> <decorator-section name= "search-results" > <include-form name= "listLookupProduct" location= "component://product/widget/catalog/FieldLookupForms.xml" /> </decorator-section> </decorator-screen> </widgets> </section> </screen> then after you try to search product on lookup field, product should not show on auto-complete.
        Hide
        soledad Nicolas Malin added a comment -

        Ok I review the patch and do some test.

        I have a second proposal with these changes :

        • We check only if conditionDates is present on context
          • if yes analyse from/thruDateName and the date value
          • if both from/thruDateName are empty, use default fromDate, thruDate

        Advantage :

        • quick to activate by default the filter
        • possibility to realize a filter only on the fromDateName (or thruDateName)

        example :
        default with fromDate thruDate

         <set field="conditionDates.default" value="Y"/>
        

        only on salesDiscontinuationDate

        <set field="conditionDates.thruDateName" value="salesDiscontinuationDate"/>
        

        only on fromDate

        <set field="conditionDates.fromDateName" value="fromDate"/>
        

        What do you thinks about this last version ?

        Show
        soledad Nicolas Malin added a comment - Ok I review the patch and do some test. I have a second proposal with these changes : We check only if conditionDates is present on context if yes analyse from/thruDateName and the date value if both from/thruDateName are empty, use default fromDate, thruDate Advantage : quick to activate by default the filter possibility to realize a filter only on the fromDateName (or thruDateName) example : default with fromDate thruDate <set field= "conditionDates. default " value= "Y" /> only on salesDiscontinuationDate <set field= "conditionDates.thruDateName" value= "salesDiscontinuationDate" /> only on fromDate <set field= "conditionDates.fromDateName" value= "fromDate" /> What do you thinks about this last version ?
        Hide
        kongrath Kongrath Suankaewmanee added a comment -

        Yes, I agree with the new code update.

        Show
        kongrath Kongrath Suankaewmanee added a comment - Yes, I agree with the new code update.
        Hide
        jacques.le.roux Jacques Le Roux added a comment -

        I also like Nicolas's last patch

        Show
        jacques.le.roux Jacques Le Roux added a comment - I also like Nicolas's last patch
        Hide
        pfm.smits Pierre Smits added a comment -

        Looking at the patch, it feels (at least to me) that the following is more appropriate:

        • renaming the ?Name variables to ?Var (e.g. fromDateName to fromDateVar), so that is more inline with general conventions.

        Furthermore, whether or not to have a filter on any specific element within a search form should be a configurable aspect for optimal UX. But that should be addressed in a separate ISSUE.

        Show
        pfm.smits Pierre Smits added a comment - Looking at the patch, it feels (at least to me) that the following is more appropriate: renaming the ?Name variables to ?Var (e.g. fromDateName to fromDateVar), so that is more inline with general conventions. Furthermore, whether or not to have a filter on any specific element within a search form should be a configurable aspect for optimal UX. But that should be addressed in a separate ISSUE.
        Hide
        jacques.le.roux Jacques Le Roux added a comment -

        +1 for optimal UX

        Show
        jacques.le.roux Jacques Le Roux added a comment - +1 for optimal UX
        Hide
        soledad Nicolas Malin added a comment -

        Pierre,

        renaming the ?Name variables to ?Var (e.g. fromDateName to fromDateVar), so that is more inline with general conventions.

        I ear your remark, but I'm not totally compliant with this for two point :

        • ?Name is a abbrev to fieldName related of GenericValue concept
        • fromDateName is present 68 occurrence on ofbiz code instead of 0 for fromDateVar : so I prefer to not introduce an other syntax for the same element on this issue and manage the replacement if it's really needed on an other issue

        +1 for Ux but like you said it's an other issue

        Show
        soledad Nicolas Malin added a comment - Pierre, renaming the ?Name variables to ?Var (e.g. fromDateName to fromDateVar), so that is more inline with general conventions. I ear your remark, but I'm not totally compliant with this for two point : ?Name is a abbrev to fieldName related of GenericValue concept fromDateName is present 68 occurrence on ofbiz code instead of 0 for fromDateVar : so I prefer to not introduce an other syntax for the same element on this issue and manage the replacement if it's really needed on an other issue +1 for Ux but like you said it's an other issue
        Hide
        soledad Nicolas Malin added a comment -

        I commited the last patch on trunk at rev 1750856

        Thanks Kongrath for the submit and all other for remarks

        Pierre, you know, feel free to open issue for your ideas ^^

        Show
        soledad Nicolas Malin added a comment - I commited the last patch on trunk at rev 1750856 Thanks Kongrath for the submit and all other for remarks Pierre, you know, feel free to open issue for your ideas ^^

          People

          • Assignee:
            soledad Nicolas Malin
            Reporter:
            kongrath Kongrath Suankaewmanee
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development