Changes

Property Direct Edit (Client)

4,751 bytes added, 06:38, 5 March 2024
/* Supported property types */
== Supported property types ==
In {{UBIK}}, we provide default templates for some most frequently used property types. However, you can use your own templates, controls, etc. as you like to deal with these property types or even more (as long as you can find suitable UI controls for dealing with these types). Direct editing properties also support [[Min Max Properties]].
<tabs>
<tab name="UWP">
* GeoData: named as UBIKPropertyDirectItemGeoData.
* With selective list items: named as UBIKPropertyDirectItemList.
 
{{Hint|Due to the limited screen size of most mobile devices, direct editing is not enabled by default in the Xamarin clients.}}
=== For MRO-Tasks: ===
* GeoData: named as UBIKTaskPropertyGeoData.
* With selective list items: named as UBIKTaskPropertyList.
 
{{Hint|Due to the limited screen size of most mobile devices, direct editing is not enabled by default for DateTime and GeoData types in the Xamarin clients.}}
[[Category:Client|Property Direct Edit (Client)]]
* '''ValueItem.PropertyValue''': This is the value of property stored at the PropertyViewModel which can differ from the underlying property value because there can be editing changes not yet confirmed/saved. It can be read from and written to by the text box;
* '''DisplayValue''': This is the textual version of ValueItem.PropertyValue used for displaying when the InEditing is false;
* '''StartDirectEditCommand''': Sets InEdit InEditing to true and starts the direct editing session. In the example, this is linked to the tapped event of the entire template area;* '''ConfirmEditCommand''': Confirms the edit and sets InEdit InEditing to false. Even if the property value is not changed, this will give the property a new validation timestamp, technically modifying the property;<tabs>Optional command parameter for ConfirmEditCommand: ToValidate - Whether a validation timestamp should be added even if the value is unchanged when confirmed. Defaults to true if unspecified.<tab name="UWP"><source lang = "xml"> <Button ... xmlns:uc="using:UBIK.WinX.Controls" Command="{Binding ConfirmEditCommand}"> <Button.CommandParameter> <uc:KeyValueList> <uc:KeyValueParameter Key="ToValidate" Value="false" /> </uc:KeyValueList> </Button.CommandParameter> </Button></source></tab> <tab name="Xamarin"><source lang = "xml"> <Button ... xmlns:classes="clr-namespace:UBIK.CPL.Classes;assembly=UBIK.CPL" Command="{Binding ConfirmEditCommand}"> <Button.CommandParameter> <classes:KeyValueList> <classes:KeyValueParameter Key="ToValidate" Value="false" /> </classes:KeyValueList> </Button.CommandParameter> </Button></source></tab></tabs>
* '''SaveAndCommitCommand''': In addition to confirming the edit, this also saves the changes to the underlying property, saves the owner object and attempts to commit it if the sync mode allows;
* '''ResetCommand''': Resets the underlying property to its last known server state, saves the owner object and attempts to commit it if the sync mode allows;
* '''DiscardChangeCommand''': Discards all changes made at the PropertyViewModel level that not yet saved to the underlying property;
* '''DeleteValueCommand''': Sets the underlying property's value(s) to null and erases its validation timestamp, saves the owner object and attempts to commit it if the sync mode allows;
<tabs>
Optional command parameter for ResetCommand and DeleteValueCommand: AutoSave - Whether the change(s) to the property and the object should be saved right after the execution of these commands. Defaults to true if unspecified.
<tab name="UWP">
<source lang = "xml">
<Button ...
xmlns:uc="using:UBIK.WinX.Controls"
Command="{Binding DeleteValueCommand}">
<Button.CommandParameter>
<uc:KeyValueList>
<uc:KeyValueParameter Key="AutoSave" Value="false" />
</uc:KeyValueList>
</Button.CommandParameter>
</Button>
</source>
</tab>
 
<tab name="Xamarin">
<source lang = "xml">
<Button ...
xmlns:classes="clr-namespace:UBIK.CPL.Classes;assembly=UBIK.CPL"
Command="{Binding DeleteValueCommand}">
<Button.CommandParameter>
<classes:KeyValueList>
<classes:KeyValueParameter Key="AutoSave" Value="false" />
</classes:KeyValueList>
</Button.CommandParameter>
</Button>
</source>
</tab>
</tabs>
* '''DiscardChangeCommand''': Discards all changes made at the PropertyViewModel level that are not yet saved to the underlying property;
* '''CancelEditCommand''': Cancels the current editing session and discards all changes made at the PropertyViewModel level '''in that session''' (different from DiscardChangeCommand).
{{Hint|Once again, you can use the [[Developer_Mode]] to find out more about the PropertyViewModel, like where they are available and how they can be accessed in XAML, or what other members are available underneath, etc.}}
 
=== ValueItem.PropertyValue or ValueItem.PropertyValueSessionless {{Version/WinXSince|4.4}}{{Version/XamarinSince|4.4}} ===
When it comes to property editing, there's the concept of edit sessions. A property editor always entails a session which starts when the editor is opened and ends when the editor is closed.
However, this could be different in direct editing. For example,
* The standard UI in {{UBIK}} for direct string editing still has sessions. The session starts when you click on the displayed value text and it turns into a text box for value input. It ends when you confirm the input value and the text box turns back into the displayed value text.
* On the other hand, the direct boolean editing is, for example, sessionless. This is because the UI displays a check box the entire time and there's no way to tell the start or the end of a session.
 
 
For most value types (e.g. where typing is involved during direct editing), the session concept still applies. '''ValueItem.PropertyValue''' should be used in bindings in such cases. Otherwise, the input values might be lost during editing. In other cases where direct editing is sessionless, '''ValueItem.PropertyValueSessionless''' should be used. Otherwise, the input value will be rejected since the property is technically speaking not in any edit session.
 
{{Hint|If you are unsure whether '''ValueItem.PropertyValue''' or '''ValueItem.PropertyValueSessionless''' should be used for a certain property type, go with the former. Because most types do have sessions in their direct editing UI. Also, the problem of misusing the former can be seen immediately, namely the editing doesn't work, whereas misusing the latter can lead to more issues that are hard to notice at first.}}
 
[[Category:Client|Property Direct Edit (Client)]]
[[Category:Version 4.0|Property Direct Edit (Client)]]
[[Category:WinX|Property Direct Edit (Client)]]
[[Category:Xamarin|Property Direct Edit (Client)]]
== Relevant types ==
<tab name="DateTime Control UWP">
The DateTime Control has CalendarControl and TimeControl both have an additional Event called "DateTimeChanged" that is called when confirming a value on the flyoutpickers.
<source lang = "xml">
<controls:UBIKCalendarControl DateString="{Binding ValueItem.PropertyValue.Date, Mode=TwoWay}">
<tab name="DateTimeControl Xamarin">
The CalendarControl has an additional Event called "DateSelected" that is called when confirming a value on the flyoutpickers. The TimeControl doesn't have has a similar "TimeSelected" Event (Note that this feature yet.event may have wrong behaviour on iOS)
<source lang = "xml">
<DatePicker Date="{Binding PropertyViewModel.ValueItem.PropertyValue.Date, Converter={StaticResource StringToDateTimeTypesConverter}">
<DatePicker.Behaviors>
<behaviors:EventToCommandBehavior EventName="DateSelected" Command="{Binding PropertyViewModel.ConfirmEditCommand}"/>
</DatePicker.Behaviors>
</DatePicker>
<ctrls:TimePickerExt Time="{Binding PropertyViewModel.ValueItem.PropertyValue.Time, Converter={StaticResource StringToDateTimeTypesConverter}">
<ctrls:TimePickerExt.Behaviors>
<behaviors:EventToCommandBehavior EventName="TimeSelected" Command="{Binding PropertyViewModel.ConfirmEditCommand}"/>
</ctrls:TimePickerExt.Behaviors>
</ctrls:TimePickerExt>
</source>
</tab>
234
edits

Help improve this page!