Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-8546 Add a diff feature to compare two documents or two versions of a document
  3. NXP-8596

Allow use of layouts and widgets to display the diff result, and write sample widgets

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.6
    • Component/s: Diff
    • Tags:
    • Backlog priority:
      350

      Description

      There are several levels of configurability needed to get a nice and pluggable diff display.

      1. Being able to manage the schemas to be displayed in the diff result, and in what order. Same for the fields of each schema, and for the complex item sub-fields.
        For example, lets say I only want to display the last modified date, the subjects and the note in that specific order, I can add this contribution:
        <diffDisplay name="default">
          <diffBlocs>
            <diffBloc name="general" label="label.general">
              <fields>
                <field name="dc:modified" />
                <field name="dc:subjects" />
              </fields>
            </diffBloc>
            <diffBloc name="note" label="label.note">
              <fields>
                <field name="note:note" />
              </fields>
              <fields>
                <field name="files:files">
                  <items>
                    <item name="filename"/>
                    <item name="file"/>
                  </items>
                </field>
              </fields>
            </diffBloc>
          </diffBlocs>
        </diffDisplay>
        
      2. Being able to manage the widgets used for the fields displayed in the diff result.
        For example, I want to define a generic widget of type datetime used for all the fields of type date (the type information is known by the PropertyDiff object).
        I might also want to define a specific widget for a directory based field, to indicate on which directory the field is based.
        The existing LayoutStore service fits this need, as it allows to declare widget definitions independently from any layout, with specifying or not field definitions.
        For this example, I would then add this contribution to the widgets extension point of the LayoutStore component:
        <widget name="date" type="datetime">
          ...
          <properties widgetMode="any">
            <property name="pattern">#{nxu:basicDateAndTimeFormater()}</property>
            <property name="timezone">#{timeZone}</property>
          </properties>
        </widget>
        <widget name="subjects" type="selectOneDirectory">
          ...
          <properties mode="any">
            <property name="directoryName">topic</property>
            <property name="localize">true</property>
          </properties>
        </widget>
        

        What needs to be done here is a DiffDisplayService to build an on the fly WidgetDefinition for a given field, first based on the field name then with a fallback on its type if no widget matches the field name.
        So in order to display dc:modified and dc:subjects:

        • as there is no widget registered with the name modified, the service is falling back to a generic widget named with the field type date, which it finds and uses;
        • as there is a widget registered with the name subjects, the service uses it for this field.
          In both cases, the service also sets the FieldDefinitions of the WidgetDefinition.

      Finally, the service can easily build a LayoutDefinition for the dublincore schema based on the 2 previous points.
      And we can just use the following tag to display the diff result:

      <nxl:layout definition=#{diffDisplayBean.getLayoutDefinition('dublincore')} value=#{diffDisplay.getSchema('dublincore')} />
      

      diffDisplayBean being a Seam component exposing the DiffDisplayService API and diffDisplay the POJO holding the diff result.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ataillefer Antoine Taillefer
                Reporter:
                ataillefer Antoine Taillefer
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 4 days
                  4d
                  Remaining:
                  Time Spent - 3 days, 3 hours Remaining Estimate - 4 hours
                  4h
                  Logged:
                  Time Spent - 3 days, 3 hours Remaining Estimate - 4 hours
                  3d 3h