[MGNLUI-5656] Improve Upload Field implementation Created: 10/Feb/20  Updated: 18/Feb/21  Resolved: 21/Feb/20

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: None
Fix Version/s: 6.2

Type: Task Priority: Neutral
Reporter: Rishab Dhar Assignee: Rishab Dhar
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0.25d
Time Spent: 5m
Original Estimate: Not Specified

Attachments: PNG File damupload-field-existing-asset.png     PNG File save-empty-media-field.png     PNG File upload-new-asset-updates-media-field.png    
Issue Links:
Problem/Incident
causes EXTDAM-122 Remove custom UploadFieldListenerFactory Closed
Relates
relates to MGNLDAM-939 JCR DAM has fixed nodetypes for node ... Closed
relates to MGNLDAM-822 Asset detail editor - validation for ... Closed
causality
is causing MGNLUI-5886 2 or more UploadFields cannot be used... Closed
documentation
to be documented by MGNLUI-5680 DOC: UploadViewDefinition Closed
duplicate
is duplicated by MGNLUI-5621 Form does not validate uploadField wh... Closed
Template:
Acceptance criteria:
Empty
Task DoR:
Empty
Documentation update required:
Yes
Date of First Response:
Sprint: UI Framework 16, UI Framework 17
Story Points: 5

 Description   

Current solution involves composite field based solution and requires the presence of redundant static fields for dimensions (width and height) and file name. Those are quirky implementation-wise and also are buggy.

The following improvements should be made to the Upload Field implementation:

  • Attach all metadata information that is part of a File to the UploadField (removing the need for redundant static fields).
  • Add required property and validation to UploadField
  • Enable adding custom factoryClass for the UploadField to maintain flexibility in adding new features to the UploadField (DamUploadField in Assets app).
  • Remove redundant static fields from Assets app (and update the app descriptor for the improved UploadField) 
  • Extract ValueBoundProperty interface from info.magnolia.ui.field.FieldDefinition, which enables adding a Value based property trait to both simple FieldDefinition (which always have a value) or a info.magnolia.ui.editor.ComplexPropertyDefinition (which may or may not have a Value trait).


 Comments   
Comment by Rishab Dhar [ 20/Feb/20 ]

The improvement does the following:

  • Extract ValueBoundProperty for form fields that can have a value - FieldDefinitions and Hybrid ComplexFields. FieldDefinitions automatically are ValueBoundProperty.
  • Introduce datasource generic UploadView as ValueBoundProperty and ComplexProperty with invisible hidden fields to update state information of the uploaded asset.
  • Introduce validator for the UploadView to configure UploadView as required ComplexProperty. (solves the issue MGNLDAM-822).
  • Update the UploadField to maintain File state in FileInfo wrapper and expose it to DamUploadField, which is updated to use the new API.
  • Update JUnit tests for DamUploadField.
  • Add Media label for DamUploadField in dam app.
Comment by Rishab Dhar [ 24/Feb/20 ]

Documentation update required

The newly introduced UploadViewDefinition class allows:

  • The DAM upload field to be used by configuring a custom factoryClass for the field (in this case, info.magnolia.dam.app.field.factory.DamUploadFieldFactory). If no factory class is configured, the default upload field will be created.
  • The upload field to be marked as required to display validation errors in the UI for an empty field.
upload:
 factoryClass: info.magnolia.dam.app.field.factory.DamUploadFieldFactory
 class: info.magnolia.ui.editor.UploadViewDefinition
 required: true
 itemProvider:
 $type: jcrChildNodeProvider
 nodeName: jcr:content
Comment by Šimon Demočko [ 18/Nov/20 ]

The doc update was supposed to be addressed in MGNLUI-6215, but as per comments on that ticket we won't do it. TL;DR: UploadViewDefinition is MgnlDeprecated, shouldn't be used by externals, we only use it internally.

Generated at Mon Feb 12 09:28:44 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.