diff --git a/framework/.actionScriptProperties b/framework/.actionScriptProperties index d75926b..1c64242 100644 --- a/framework/.actionScriptProperties +++ b/framework/.actionScriptProperties @@ -12,3 +12,4 @@ + diff --git a/framework/.project b/framework/.project index 4c45fb0..94a82a1 100644 --- a/framework/.project +++ b/framework/.project @@ -1,18 +1,18 @@ - - - restfulx - - - - - - com.adobe.flexbuilder.project.flexbuilder - - - - - - com.adobe.flexbuilder.project.flexlibnature - com.adobe.flexbuilder.project.actionscriptnature - - + + + restflex-flex4 + + + + + + com.adobe.flexbuilder.project.flexbuilder + + + + + + com.adobe.flexbuilder.project.flexlibnature + com.adobe.flexbuilder.project.actionscriptnature + + diff --git a/framework/.settings/com.adobe.flexbuilder.project.prefs b/framework/.settings/com.adobe.flexbuilder.project.prefs new file mode 100644 index 0000000..b1c90c3 --- /dev/null +++ b/framework/.settings/com.adobe.flexbuilder.project.prefs @@ -0,0 +1,3 @@ +#Thu Dec 09 14:01:08 PST 2010 +eclipse.preferences.version=1 +upgradeSDK/fb4=Flex 4.1 Air 2.5 diff --git a/framework/src/org/restfulx/components/rx/RxAutoComplete.as b/framework/src/org/restfulx/components/rx/RxAutoComplete.as index 311fc50..b0b1d76 100644 --- a/framework/src/org/restfulx/components/rx/RxAutoComplete.as +++ b/framework/src/org/restfulx/components/rx/RxAutoComplete.as @@ -21,6 +21,15 @@ * * Redistributions of files must retain the above copyright notice. ******************************************************************************/ + +/**FLEX 4 Changes*************************************************************** + * + * Changed selectionBeginIndex to selectionAnchorPosition + * + * Changed setSelection to selectRange + * + ******************************************************************************/ + package org.restfulx.components.rx { import flash.events.Event; import flash.events.KeyboardEvent; @@ -392,8 +401,9 @@ package org.restfulx.components.rx { showDropdown = true; } else if (dropdown) { if (typedTextChanged) { - cursorPosition = textInput.selectionBeginIndex; - + //cursorPosition = textInput.selectionBeginIndex; + cursorPosition = textInput.selectionAnchorPosition; // Flex 4 + if (ArrayCollection(dataProvider).length) { if (!itemPreselected && !itemShown) { showDropdown = true; @@ -427,18 +437,21 @@ package org.restfulx.components.rx { showDropdown = false; showingDropdown = true; if (dropdownClosed) dropdownClosed = false; - textInput.setSelection(0, textInput.text.length); + //textInput.setSelection(0, textInput.text.length); + textInput.selectRange(0, textInput.text.length); // Flex 4 } else if (dropdown) { if (typedTextChanged) { //This is needed because a call to super.updateDisplayList() iset the text // in the textInput to "" and the value typed by the user gets losts textInput.text = _typedText; - textInput.setSelection(cursorPosition, cursorPosition); + // textInput.setSelection(cursorPosition, cursorPosition); + textInput.selectRange(cursorPosition, cursorPosition); //Flex 4 typedTextChanged = false; } else if (typedText) { //Sets the selection when user navigates the suggestion list through //arrows keys. - textInput.setSelection(0, textInput.text.length); + //textInput.setSelection(0, textInput.text.length); + textInput.selectRange(0, textInput.text.length); //Flex4 } if (clearingText) clearingText = false; @@ -514,11 +527,13 @@ package org.restfulx.components.rx { // field to original text if (event.keyCode == Keyboard.UP && prevIndex == 0) { textInput.text = _typedText; - textInput.setSelection(textInput.text.length, textInput.text.length); + //textInput.setSelection(textInput.text.length, textInput.text.length); + textInput.selectRange(textInput.text.length, textInput.text.length); // Flex 4 selectedIndex = -1; } else if (event.keyCode == Keyboard.ESCAPE && showingDropdown) { textInput.text = _typedText; - textInput.setSelection(textInput.text.length, textInput.text.length); + //textInput.setSelection(textInput.text.length, textInput.text.length); + textInput.selectRange(textInput.text.length, textInput.text.length); //Flex 4 showingDropdown = false; dropdownClosed = true; } else if (event.keyCode == Keyboard.ENTER || event.keyCode == Keyboard.TAB) { @@ -561,7 +576,8 @@ package org.restfulx.components.rx { super.close(event); if (selectedIndex == 0) { textInput.text = selectedLabel; - textInput.setSelection(cursorPosition, textInput.text.length); + //textInput.setSelection(cursorPosition, textInput.text.length); // Flex 4 + textInput.selectRange(cursorPosition, textInput.text.length); } } } diff --git a/framework/src/org/restfulx/controllers/CacheController.as b/framework/src/org/restfulx/controllers/CacheController.as index 74008aa..657cead 100644 --- a/framework/src/org/restfulx/controllers/CacheController.as +++ b/framework/src/org/restfulx/controllers/CacheController.as @@ -158,7 +158,7 @@ package org.restfulx.controllers { } RxUtils.cleanupModelReferences(model, fqn); ModelsCollection(data[fqn]).removeItem(model); - Rx.models.dispatchEvent(new CacheUpdateEvent(fqn, CacheUpdateEvent.DESTROY, serviceProvider)); + Rx.models.dispatchEvent(new CacheUpdateEvent(fqn, CacheUpdateEvent.DESTROY, serviceProvider, model)); model.dispatchEvent(new AfterDestroyEvent); } } diff --git a/framework/src/org/restfulx/serializers/GenericSerializer.as b/framework/src/org/restfulx/serializers/GenericSerializer.as index b439189..a0f73fc 100644 --- a/framework/src/org/restfulx/serializers/GenericSerializer.as +++ b/framework/src/org/restfulx/serializers/GenericSerializer.as @@ -210,6 +210,7 @@ package org.restfulx.serializers { } object[targetName] = ref; + processHasManyThroughRelationships(ref,targetType); } else if (isNestedArray) { object[targetName] = processNestedArray(attribute, targetType, disconnected); } else if (isNestedObject && !disconnected) { @@ -221,7 +222,11 @@ package org.restfulx.serializers { } else { if (defaultValue == null) { try { - object[targetName] = ""; + if(object[targetName] is Number){ + object[targetName] = NaN; + }else{ + object[targetName] = ""; + } } catch (e:Error) { object[targetName] = null; } @@ -333,10 +338,18 @@ package org.restfulx.serializers { // form 2 e.g. object[authors] } else if (object.hasOwnProperty(localSingleName) && object.hasOwnProperty(refNamePlural)) { - if (object[refNamePlural] == null) { - object[refNamePlural] = new ModelsCollection; - } - object[localSingleName][relationship["attribute"]] = object[refNamePlural]; + for each(var item:Object in ModelsCollection(object[refNamePlural])){ + if (checkConditions(item, conditions)) { + if (items.hasItem(item)) { + items.setItem(item); + } else { + items.addItem(item); + } + }else if (items.hasItem(item)) { + items.removeItem(item); + } + } + object[localSingleName][relationship["attribute"]] = items; } } catch (e:Error) { // do something diff --git a/tests/src/restfulx/test/cases/models/HasManyThroughRelationshipsTest.as b/tests/src/restfulx/test/cases/models/HasManyThroughRelationshipsTest.as index fa638cb..d8b70c6 100644 --- a/tests/src/restfulx/test/cases/models/HasManyThroughRelationshipsTest.as +++ b/tests/src/restfulx/test/cases/models/HasManyThroughRelationshipsTest.as @@ -90,17 +90,17 @@ package restfulx.test.cases.models { var firstStore:Store = stores.withId("458237344") as Store; var firstBook:Book = books.withId("404163108") as Book; var firstAuthor:Author = authors.withId("404163108") as Author; - + assertEquals(4, stores.length); - assertEquals(4, books.length); - assertEquals(4, authors.length); - + assertEquals(5, books.length); + assertEquals(6, authors.length); + assertEquals("Store4NameString", firstStore.name); - assertEquals(1, firstStore.authors.length); - assertEquals(1, firstStore.books.length); + assertEquals(3, firstStore.authors.length); + assertEquals(2, firstStore.books.length); assertEquals("Author4NameString", Author(firstStore.authors.getItemAt(0)).name); assertEquals("Book4NameString", Book(firstStore.books.getItemAt(0)).name); - assertEquals(1, firstStore.randomAuthors.length); + assertEquals(3, firstStore.randomAuthors.length); assertEquals("Author4NameString", Author(firstStore.randomAuthors.getItemAt(0)).name); Rx.models.removeEventListener(CacheUpdateEvent.ID, onCacheUpdateForm2); } diff --git a/tests/src/restfulx/test/responses/authors.xml b/tests/src/restfulx/test/responses/authors.xml index d2fc11e..d1b3e80 100644 --- a/tests/src/restfulx/test/responses/authors.xml +++ b/tests/src/restfulx/test/responses/authors.xml @@ -28,4 +28,18 @@ Author3NameString 2008/12/09 00:02:40 + + 1023124238 + 2008/12/09 00:02:40 + 790999880 + Author5NameString + 2008/12/09 00:02:40 + + + 1023124238 + 2008/12/09 00:02:40 + 790999881 + Author6NameString + 2008/12/09 00:02:40 + \ No newline at end of file diff --git a/tests/src/restfulx/test/responses/books.xml b/tests/src/restfulx/test/responses/books.xml index 5e0afad..e2d8f74 100644 --- a/tests/src/restfulx/test/responses/books.xml +++ b/tests/src/restfulx/test/responses/books.xml @@ -7,6 +7,13 @@ 458237344 2008/12/09 00:02:40 + + 2008/12/09 00:02:40 + 1023124238 + Book5NameString + 458237344 + 2008/12/09 00:02:40 + 2008/12/09 00:02:40 968145068