1- angular . module ( "umbraco" ) . controller ( "Our.Umbraco.PropertyList.Controllers.RepeatableDataTypeController" ,
2- function ( $scope , contentTypeResource , umbPropEditorHelper ) {
1+ angular . module ( "umbraco" ) . controller ( "Our.Umbraco.PropertyList.Controllers.PropertyListController" , [
2+ "$scope" ,
3+ "contentTypeResource" ,
4+ "Our.Umbraco.PropertyList.Resources.PropertyListResources" ,
5+ "umbPropEditorHelper" ,
6+ function ( $scope , contentTypeResource , propertyListResource , umbPropEditorHelper ) {
37
48 //console.debug("pl", $scope.model.config.dataType, $scope.model.value);
59
6- var dataTypeId = $scope . model . config . dataType ;
7- var minItems = $scope . model . config . minItems || 0 ;
8- var maxItems = $scope . model . config . maxItems || 0 ;
10+ var dataTypeGuid = $scope . model . config . dataType ;
11+ var minItems = $scope . model . config . minItems || 0 ;
12+ var maxItems = $scope . model . config . maxItems || 0 ;
913
10- $scope . isConfigured = dataTypeId != null ;
14+ $scope . isConfigured = dataTypeGuid != null ;
1115
1216 if ( $scope . isConfigured ) {
1317
1418 if ( ! angular . isObject ( $scope . model . value ) )
1519 $scope . model . value = undefined ;
1620
1721 $scope . model . value = $scope . model . value || {
18- dtdId : dataTypeId ,
22+ dtd : dataTypeGuid ,
1923 values : [ ]
2024 } ;
2125
2226 $scope . prompts = { } ;
2327
24- contentTypeResource . getPropertyTypeScaffold ( dataTypeId ) . then ( function ( propertyType ) {
28+ propertyListResource . getPropertyTypeScaffoldByKey ( dataTypeGuid ) . then ( function ( propertyType ) {
2529
2630 $scope . propertyType = propertyType ;
2731
7680 } ;
7781
7882 $scope . model . controls . splice ( idx , 0 , control ) ;
83+ $scope . setDirty ( ) ;
7984 }
8085
8186 $scope . deleteContent = function ( evt , idx ) {
8287 $scope . model . controls . splice ( idx , 1 ) ;
88+ $scope . setDirty ( ) ;
8389 }
8490
8591 $scope . sortableOptions = {
9298 cursorAt : {
9399 top : 0
94100 } ,
95- //update: function (e, ui) {
96- // _.each($scope.model.controls, function (itm, idx) {
97- // console.debug("sorted", itm, idx)
98- // });
99- //}
101+ update : function ( e , ui ) {
102+ $scope . setDirty ( ) ;
103+ }
104+ } ;
105+
106+ $scope . setDirty = function ( ) {
107+ if ( $scope . propertyForm ) {
108+ $scope . propertyForm . $setDirty ( ) ;
109+ }
100110 } ;
101111
102112 var unsubscribe = $scope . $on ( "formSubmitting" , function ( ev , args ) {
106116 tmpValues [ idx ] = control . value ;
107117 } ) ;
108118
109- $scope . model . value . values = ! _ . isEmpty ( tmpValues ) ? tmpValues : [ ] ;
110- $scope . model . value . dtdId = dataTypeId ;
119+ $scope . model . value = {
120+ dtd : dataTypeGuid ,
121+ values : ! _ . isEmpty ( tmpValues ) ? tmpValues : [ ]
122+ } ;
111123 } ) ;
112124
113125 $scope . $on ( '$destroy' , function ( ) {
114126 unsubscribe ( ) ;
115127 } ) ;
116128
117- } ) ;
129+ } ] ) ;
118130
119- angular . module ( "umbraco" ) . controller ( "Our.Umbraco.PropertyList.Controllers.DataTypePickerController" ,
120- function ( $scope , contentTypeResource , dataTypeResource , dataTypeHelper ) {
131+ angular . module ( "umbraco" ) . controller ( "Our.Umbraco.PropertyList.Controllers.DataTypePickerController" , [
132+ "$scope" ,
133+ "contentTypeResource" ,
134+ "dataTypeHelper" ,
135+ "dataTypeResource" ,
136+ "entityResource" ,
137+ "Our.Umbraco.PropertyList.Resources.PropertyListResources" ,
138+ function ( $scope , contentTypeResource , dataTypeHelper , dataTypeResource , entityResource , propertyListResource ) {
121139
122140 if ( ! $scope . model . property ) {
123141
124142 $scope . model . property = { } ;
125143
126144 if ( $scope . model . value ) {
127- dataTypeResource . getById ( $scope . model . value ) . then ( function ( dataType ) {
128-
145+ propertyListResource . getDataTypeByKey ( $scope . model . value ) . then ( function ( dataType ) {
129146 // update editor
130147 $scope . model . property . editor = dataType . selectedEditor ;
131148 $scope . model . property . dataTypeId = dataType . id ;
132149 $scope . model . property . dataTypeIcon = dataType . icon ;
133150 $scope . model . property . dataTypeName = dataType . name ;
134-
135151 } ) ;
136152 }
137153 }
@@ -141,8 +157,10 @@ angular.module("umbraco").controller("Our.Umbraco.PropertyList.Controllers.DataT
141157 vm . openEditorPickerOverlay = openEditorPickerOverlay ;
142158 vm . openEditorSettingsOverlay = openEditorSettingsOverlay ;
143159
144- function setDataTypeId ( dataTypeId ) {
145- $scope . model . value = dataTypeId ;
160+ function setModelValue ( dataTypeId ) {
161+ entityResource . getById ( dataTypeId , "DataType" ) . then ( function ( entity ) {
162+ $scope . model . value = entity . key ;
163+ } ) ;
146164 } ;
147165
148166 function openEditorPickerOverlay ( property ) {
@@ -154,7 +172,7 @@ angular.module("umbraco").controller("Our.Umbraco.PropertyList.Controllers.DataT
154172
155173 vm . editorPickerOverlay . submit = function ( model ) {
156174
157- setDataTypeId ( model . property . dataTypeId ) ;
175+ setModelValue ( model . property . dataTypeId ) ;
158176
159177 vm . editorPickerOverlay . show = false ;
160178 vm . editorPickerOverlay = null ;
@@ -186,7 +204,7 @@ angular.module("umbraco").controller("Our.Umbraco.PropertyList.Controllers.DataT
186204
187205 contentTypeResource . getPropertyTypeScaffold ( newDataType . id ) . then ( function ( propertyType ) {
188206
189- setDataTypeId ( newDataType . id ) ;
207+ setModelValue ( newDataType . id ) ;
190208
191209 // update editor
192210 property . config = propertyType . config ;
@@ -214,5 +232,4 @@ angular.module("umbraco").controller("Our.Umbraco.PropertyList.Controllers.DataT
214232
215233 }
216234
217- } ) ;
218-
235+ } ] ) ;
0 commit comments