Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flex4 #54

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions framework/.actionScriptProperties
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
<modules/>
<buildCSSFiles/>
</actionScriptProperties>

36 changes: 18 additions & 18 deletions framework/.project
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>restfulx</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.adobe.flexbuilder.project.flexbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.adobe.flexbuilder.project.flexlibnature</nature>
<nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>restflex-flex4</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.adobe.flexbuilder.project.flexbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.adobe.flexbuilder.project.flexlibnature</nature>
<nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
</natures>
</projectDescription>
3 changes: 3 additions & 0 deletions framework/.settings/com.adobe.flexbuilder.project.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Thu Dec 09 14:01:08 PST 2010
eclipse.preferences.version=1
upgradeSDK/fb4=Flex 4.1 Air 2.5
32 changes: 24 additions & 8 deletions framework/src/org/restfulx/components/rx/RxAutoComplete.as
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion framework/src/org/restfulx/controllers/CacheController.as
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
23 changes: 18 additions & 5 deletions framework/src/org/restfulx/serializers/GenericSerializer.as
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
14 changes: 14 additions & 0 deletions tests/src/restfulx/test/responses/authors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,18 @@
<name>Author3NameString</name>
<updated_at type="datetime">2008/12/09 00:02:40</updated_at>
</author>
<author>
<book_id type="integer">1023124238</book_id>
<created_at type="datetime">2008/12/09 00:02:40</created_at>
<id type="integer">790999880</id>
<name>Author5NameString</name>
<updated_at type="datetime">2008/12/09 00:02:40</updated_at>
</author>
<author>
<book_id type="integer">1023124238</book_id>
<created_at type="datetime">2008/12/09 00:02:40</created_at>
<id type="integer">790999881</id>
<name>Author6NameString</name>
<updated_at type="datetime">2008/12/09 00:02:40</updated_at>
</author>
</authors>
7 changes: 7 additions & 0 deletions tests/src/restfulx/test/responses/books.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
<store_id type="integer">458237344</store_id>
<updated_at type="datetime">2008/12/09 00:02:40</updated_at>
</book>
<book>
<created_at type="datetime">2008/12/09 00:02:40</created_at>
<id type="integer">1023124238</id>
<name>Book5NameString</name>
<store_id type="integer">458237344</store_id>
<updated_at type="datetime">2008/12/09 00:02:40</updated_at>
</book>
<book>
<created_at type="datetime">2008/12/09 00:02:40</created_at>
<id type="integer">968145068</id>
Expand Down