@@ -6,11 +6,11 @@ sap.ui.define(["sap/ui/core/mvc/Controller",
6
6
onInit : async function ( ) {
7
7
8
8
z2ui5 . oOwnerComponent = this . getOwnerComponent ( ) ;
9
- z2ui5 . oConfig . pathname = this . getView ( ) . getModel ( " http" ) . sServiceUrl ;
10
- if ( z2ui5 ?. checkLocal == true ) {
11
- z2ui5 . oConfig . pathname = window . location . href ;
9
+ z2ui5 . oConfig . pathname = z2ui5 . oOwnerComponent . getManifest ( ) [ "sap.app" ] . dataSources . http . uri ;
10
+ if ( z2ui5 ?. checkLocal == true ) {
11
+ z2ui5 . oConfig . pathname = window . location . href ;
12
12
} ;
13
-
13
+
14
14
z2ui5 . oController = new Controller ( ) ;
15
15
z2ui5 . oApp = this . getView ( ) . byId ( "app" ) ;
16
16
@@ -200,19 +200,20 @@ sap.ui.define("z2ui5/Tree", ["sap/ui/core/Control"], (Control) => {
200
200
} ,
201
201
202
202
setBackend ( ) {
203
- z2ui5 . treeState = z2ui5 . oView . byId ( this . getProperty ( "tree_id" ) ) . getBinding ( 'items' ) . getCurrentTreeState ( ) ;
203
+ z2ui5 . treeState = z2ui5 . oView . byId ( this . getProperty ( "tree_id" ) ) . getBinding ( 'items' ) . getCurrentTreeState ( ) ;
204
204
} ,
205
205
206
206
init ( ) {
207
207
z2ui5 . onBeforeRoundtrip . push ( this . setBackend . bind ( this ) ) ;
208
208
} ,
209
209
210
- renderer ( oRm , oControl ) {
211
- if ( ! z2ui5 . treeState ) return ;
210
+ renderer ( oRm , oControl ) {
211
+ if ( ! z2ui5 . treeState ) return ;
212
212
setTimeout ( ( id ) => {
213
- z2ui5 . oView . byId ( id ) . getBinding ( 'items' ) . setTreeState ( z2ui5 . treeState ) ;
214
- } , 100 , oControl . getProperty ( "tree_id" ) ) ;
215
- } } ) ;
213
+ z2ui5 . oView . byId ( id ) . getBinding ( 'items' ) . setTreeState ( z2ui5 . treeState ) ;
214
+ } , 100 , oControl . getProperty ( "tree_id" ) ) ;
215
+ }
216
+ } ) ;
216
217
} ) ;
217
218
218
219
sap . ui . define ( "z2ui5/Scrolling" , [ "sap/ui/core/Control" ] , ( Control ) => {
@@ -243,7 +244,7 @@ sap.ui.define("z2ui5/Scrolling", ["sap/ui/core/Control"], (Control) => {
243
244
try {
244
245
const element = document . getElementById ( `${ z2ui5 . oView . byId ( item . ID ) . getId ( ) } -inner` ) ;
245
246
item . V = element ? element . scrollTop : 0 ;
246
- } catch { }
247
+ } catch { }
247
248
}
248
249
} ) ;
249
250
}
@@ -668,7 +669,7 @@ sap.ui.define("z2ui5/MultiInputExt", ["sap/ui/core/Control", "sap/m/Token", "sap
668
669
let table = z2ui5 . oView . byId ( this . getProperty ( "MultiInputId" ) ) ;
669
670
if ( ! table ) {
670
671
try {
671
- // table = Core.byId(Element.getElementsByName(this.getProperty("MultiInputName"))[0].id.replace('-inner', ''));
672
+ // table = Core.byId(Element.getElementsByName(this.getProperty("MultiInputName"))[0].id.replace('-inner', ''));
672
673
} catch ( e ) {
673
674
return ;
674
675
}
@@ -697,7 +698,7 @@ sap.ui.define("z2ui5/MultiInputExt", ["sap/ui/core/Control", "sap/m/Token", "sap
697
698
698
699
sap . ui . define ( "z2ui5/SmartMultiInputExt" , [ "sap/ui/core/Control" , "sap/m/Token" , "sap/ui/core/Core" , "sap/ui/core/Element" ] , ( Control ) => {
699
700
"use strict" ;
700
-
701
+
701
702
return Control . extend ( "z2ui5.SmartMultiInputExt" , {
702
703
metadata : {
703
704
properties : {
@@ -711,7 +712,8 @@ sap.ui.define("z2ui5/SmartMultiInputExt", ["sap/ui/core/Control", "sap/m/Token",
711
712
type : "Array"
712
713
} ,
713
714
rangeData : {
714
- type : "Array"
715
+ type : "Array" ,
716
+ defaultValue : [ ]
715
717
} ,
716
718
checkInit : {
717
719
type : "Boolean" ,
@@ -725,15 +727,15 @@ sap.ui.define("z2ui5/SmartMultiInputExt", ["sap/ui/core/Control", "sap/m/Token",
725
727
}
726
728
} ,
727
729
} ,
728
-
730
+
729
731
init ( ) {
730
732
z2ui5 . onAfterRendering . push ( this . setControl . bind ( this ) ) ;
731
733
} ,
732
-
734
+
733
735
onTokenUpdate ( oEvent ) {
734
736
this . setProperty ( "addedTokens" , [ ] ) ;
735
737
this . setProperty ( "removedTokens" , [ ] ) ;
736
-
738
+
737
739
if ( oEvent . mParameters . type == "removed" ) {
738
740
let removedTokens = [ ] ;
739
741
oEvent . mParameters . removedTokens . forEach ( ( item ) => {
@@ -755,9 +757,33 @@ sap.ui.define("z2ui5/SmartMultiInputExt", ["sap/ui/core/Control", "sap/m/Token",
755
757
) ;
756
758
this . setProperty ( "addedTokens" , addedTokens ) ;
757
759
}
758
- this . setProperty ( "rangeData" , oEvent . getSource ( ) . getRangeData ( ) ) ;
760
+ const aTokens = oEvent . getSource ( ) . getTokens ( ) ;
761
+ this . setProperty ( "rangeData" , oEvent . getSource ( ) . getRangeData ( ) . map ( ( oRangeData , iIndex ) => {
762
+ oRangeData . tokenText = aTokens [ iIndex ] . getText ( ) ;
763
+ return oRangeData ;
764
+ } ) ) ;
759
765
this . fireChange ( ) ;
760
766
} ,
767
+ setRangeData ( aRangeData ) {
768
+ this . setProperty ( "rangeData" , aRangeData ) ;
769
+ this . inputInitialized ( ) . then ( ( input ) => {
770
+ input . setRangeData ( aRangeData . map ( ( oRangeData ) => {
771
+ const oRangeDataNew = { } ;
772
+ Object . entries ( oRangeData ) . forEach ( ( aEntry ) => {
773
+ const sKeyNameNew = aEntry [ 0 ] . toLowerCase ( ) ;
774
+ oRangeDataNew [ ( sKeyNameNew === "keyfield" ? "keyField" : sKeyNameNew ) ] = aEntry [ 1 ] ;
775
+ } ) ;
776
+ return oRangeDataNew ;
777
+ } ) ) ;
778
+ //we need to set token text explicitly, as setRangeData does no recalculation
779
+ input . getTokens ( ) . forEach ( ( token , index ) => {
780
+ const sTokenText = aRangeData [ index ] . TOKENTEXT ;
781
+ if ( sTokenText ) {
782
+ token . setText ( sTokenText ) ;
783
+ }
784
+ } ) ;
785
+ } ) ;
786
+ } ,
761
787
renderer ( oRm , oControl ) { } ,
762
788
setControl ( ) {
763
789
const input = z2ui5 . oView . byId ( this . getProperty ( "multiInputId" ) ) ;
@@ -769,114 +795,134 @@ sap.ui.define("z2ui5/SmartMultiInputExt", ["sap/ui/core/Control", "sap/m/Token",
769
795
}
770
796
this . setProperty ( "checkInit" , true ) ;
771
797
input . attachTokenUpdate ( this . onTokenUpdate . bind ( this ) ) ;
798
+ input . attachInnerControlsCreated ( this . onInnerControlsCreated . bind ( this ) ) ;
799
+ } ,
800
+ inputInitialized ( input ) {
801
+ return new Promise ( ( resolve , reject ) => {
802
+ if ( this . _bInnerControlsCreated ) {
803
+ resolve ( input ) ; //resolve immediately
804
+ } else {
805
+ this . _oPendingInnerControlsCreated = resolve ; //resolve later
806
+ }
807
+ } ) ;
808
+ } ,
809
+ _oPendingInnerControlsCreated : null ,
810
+ _bInnerControlsCreated : false ,
811
+ onInnerControlsCreated ( oEvent ) {
812
+ const input = oEvent . getSource ( ) ;
813
+ if ( this . _oPendingInnerControlsCreated ) {
814
+ this . _oPendingInnerControlsCreated ( input ) ;
815
+ }
816
+ this . _oPendingInnerControlsCreated = null ;
817
+ this . _bInnerControlsCreated = true ;
772
818
}
773
819
} ) ;
774
820
}
775
821
) ;
776
822
777
- sap . ui . define ( "z2ui5/CameraPicture" , [
823
+ sap . ui . define ( "z2ui5/CameraPicture" , [
778
824
"sap/ui/core/Control" ,
779
825
"sap/m/Dialog" ,
780
826
"sap/m/Button"
781
827
] , function ( Control , Dialog , Button ) {
782
828
"use strict" ;
783
829
return Control . extend ( "z2ui5.CameraPicture" , {
784
- metadata : {
785
- properties : {
786
- id : { type : "string" } ,
787
- value : { type : "string" } ,
788
- press : { type : "string" } ,
789
- autoplay : { type : "boolean" , defaultValue : true }
790
- } ,
791
- events : {
792
- "OnPhoto" : {
793
- allowPreventDefault : true ,
794
- parameters : {
795
- "photo" : {
796
- type : "string"
797
- }
798
- }
799
- }
800
- } ,
830
+ metadata : {
831
+ properties : {
832
+ id : { type : "string" } ,
833
+ value : { type : "string" } ,
834
+ press : { type : "string" } ,
835
+ autoplay : { type : "boolean" , defaultValue : true }
801
836
} ,
802
-
803
- capture : function ( oEvent ) {
804
-
805
- var video = document . querySelector ( "#zvideo" ) ;
806
- var canvas = document . getElementById ( 'zcanvas' ) ;
807
- var resultb64 = "" ;
808
- canvas . width = 200 ;
809
- canvas . height = 200 ;
810
- canvas . getContext ( '2d' ) . drawImage ( video , 0 , 0 , 200 , 200 ) ;
811
- resultb64 = canvas . toDataURL ( ) ;
812
- this . setProperty ( "value" , resultb64 ) ;
813
- this . fireOnPhoto ( {
814
- "photo" : resultb64
815
- } ) ;
837
+ events : {
838
+ "OnPhoto" : {
839
+ allowPreventDefault : true ,
840
+ parameters : {
841
+ "photo" : {
842
+ type : "string"
843
+ }
844
+ }
845
+ }
816
846
} ,
847
+ } ,
817
848
818
- onPicture : function ( oEvent ) {
819
-
820
- if ( ! this . _oScanDialog ) {
821
- this . _oScanDialog = new Dialog ( {
822
- title : "Device Photo Function" ,
823
- contentWidth : "640px" ,
824
- contentHeight : "480px" ,
825
- horizontalScrolling : false ,
826
- verticalScrolling : false ,
827
- stretch : true ,
828
- content : [
829
- new HTML ( {
830
- id : this . getId ( ) + 'PictureContainer' ,
831
- content : '<video width="600px" height="400px" autoplay="true" id="zvideo">'
832
- } ) ,
833
- new Button ( {
834
- text : "Capture" ,
835
- press : function ( oEvent ) {
836
- this . capture ( ) ;
837
- this . _oScanDialog . close ( ) ;
838
- } . bind ( this )
839
- } ) ,
840
- new HTML ( {
841
- content : '<canvas hidden id="zcanvas" style="overflow:auto"></canvas>'
842
- } ) ,
843
- ] ,
844
- endButton : new Button ( {
845
- text : "Cancel" ,
846
- press : function ( oEvent ) {
847
- this . _oScanDialog . close ( ) ;
848
- } . bind ( this )
849
- } ) ,
850
- } ) ;
851
- }
849
+ capture : function ( oEvent ) {
850
+
851
+ var video = document . querySelector ( "#zvideo" ) ;
852
+ var canvas = document . getElementById ( 'zcanvas' ) ;
853
+ var resultb64 = "" ;
854
+ canvas . width = 200 ;
855
+ canvas . height = 200 ;
856
+ canvas . getContext ( '2d' ) . drawImage ( video , 0 , 0 , 200 , 200 ) ;
857
+ resultb64 = canvas . toDataURL ( ) ;
858
+ this . setProperty ( "value" , resultb64 ) ;
859
+ this . fireOnPhoto ( {
860
+ "photo" : resultb64
861
+ } ) ;
862
+ } ,
852
863
853
- this . _oScanDialog . open ( ) ;
854
-
855
- setTimeout ( function ( ) {
856
- var video = document . querySelector ( '#zvideo' ) ;
857
- if ( navigator . mediaDevices . getUserMedia ) {
858
- navigator . mediaDevices . getUserMedia ( { video : { facingMode : { exact : "environment" } } } )
859
- . then ( function ( stream ) {
860
- video . srcObject = stream ;
861
- } )
862
- . catch ( function ( error ) {
863
- console . log ( "Something went wrong!" ) ;
864
- } ) ;
865
- }
866
- } . bind ( this ) , 300 ) ;
864
+ onPicture : function ( oEvent ) {
865
+
866
+ if ( ! this . _oScanDialog ) {
867
+ this . _oScanDialog = new Dialog ( {
868
+ title : "Device Photo Function" ,
869
+ contentWidth : "640px" ,
870
+ contentHeight : "480px" ,
871
+ horizontalScrolling : false ,
872
+ verticalScrolling : false ,
873
+ stretch : true ,
874
+ content : [
875
+ new HTML ( {
876
+ id : this . getId ( ) + 'PictureContainer' ,
877
+ content : '<video width="600px" height="400px" autoplay="true" id="zvideo">'
878
+ } ) ,
879
+ new Button ( {
880
+ text : "Capture" ,
881
+ press : function ( oEvent ) {
882
+ this . capture ( ) ;
883
+ this . _oScanDialog . close ( ) ;
884
+ } . bind ( this )
885
+ } ) ,
886
+ new HTML ( {
887
+ content : '<canvas hidden id="zcanvas" style="overflow:auto"></canvas>'
888
+ } ) ,
889
+ ] ,
890
+ endButton : new Button ( {
891
+ text : "Cancel" ,
892
+ press : function ( oEvent ) {
893
+ this . _oScanDialog . close ( ) ;
894
+ } . bind ( this )
895
+ } ) ,
896
+ } ) ;
897
+ }
867
898
868
- } ,
899
+ this . _oScanDialog . open ( ) ;
900
+
901
+ setTimeout ( function ( ) {
902
+ var video = document . querySelector ( '#zvideo' ) ;
903
+ if ( navigator . mediaDevices . getUserMedia ) {
904
+ navigator . mediaDevices . getUserMedia ( { video : { facingMode : { exact : "environment" } } } )
905
+ . then ( function ( stream ) {
906
+ video . srcObject = stream ;
907
+ } )
908
+ . catch ( function ( error ) {
909
+ console . log ( "Something went wrong!" ) ;
910
+ } ) ;
911
+ }
912
+ } . bind ( this ) , 300 ) ;
913
+
914
+ } ,
869
915
870
- renderer : function ( oRM , oControl ) {
916
+ renderer : function ( oRM , oControl ) {
871
917
872
- var oButton = new Button ( {
873
- icon : "sap-icon://camera" ,
874
- text : "Camera" ,
875
- press : oControl . onPicture . bind ( oControl ) ,
876
- } ) ;
877
- oRM . renderControl ( oButton ) ;
918
+ var oButton = new Button ( {
919
+ icon : "sap-icon://camera" ,
920
+ text : "Camera" ,
921
+ press : oControl . onPicture . bind ( oControl ) ,
922
+ } ) ;
923
+ oRM . renderControl ( oButton ) ;
878
924
879
- } ,
925
+ } ,
880
926
} ) ;
881
927
} ) ;
882
928
@@ -927,7 +973,7 @@ sap.ui.define("z2ui5/Util", [], () => {
927
973
"use strict" ;
928
974
return {
929
975
DateCreateObject : ( s ) => new Date ( s ) ,
930
- // DateAbapTimestampToDate: (sTimestamp) => new sap.gantt.misc.Format.abapTimestampToDate(sTimestamp), commented for UI5 2.x compatibility
976
+ // DateAbapTimestampToDate: (sTimestamp) => new sap.gantt.misc.Format.abapTimestampToDate(sTimestamp), commented for UI5 2.x compatibility
931
977
DateAbapDateToDateObject : ( d ) => new Date ( d . slice ( 0 , 4 ) , parseInt ( d . slice ( 4 , 6 ) ) - 1 , d . slice ( 6 , 8 ) ) ,
932
978
DateAbapDateTimeToDateObject : ( d , t = '000000' ) => new Date ( d . slice ( 0 , 4 ) , parseInt ( d . slice ( 4 , 6 ) ) - 1 , d . slice ( 6 , 8 ) , t . slice ( 0 , 2 ) , t . slice ( 2 , 4 ) , t . slice ( 4 , 6 ) ) ,
933
979
} ;
0 commit comments