Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add Delete end Update

skin button
Restyling Views
  • Loading branch information...
commit 8e0165362ee70276afe42284dbd09ac51faf72c7 1 parent 3f241f1
astucchi authored
View
2  src/MobileActionMongo.mxml
@@ -14,5 +14,5 @@
<s:ViewNavigator label="Home" width="100%" height="100%" firstView="com.kdata.mobile.presentation.MAMHomeView"/>
<s:ViewNavigator label="Settings" width="100%" height="100%" firstView="com.kdata.mobile.presentation.MAMSettings"/>
- <s:ViewNavigator label="Insert" width="100%" height="100%" firstView="com.kdata.mobile.presentation.MAMInsert"/>
+ <s:ViewNavigator label="About" width="100%" height="100%" firstView="com.kdata.mobile.presentation.MAMAbout"/>
</s:TabbedViewNavigatorApplication>
View
10 src/com/kdata/mobile/application/MongoHandler.as
@@ -49,8 +49,14 @@ package com.kdata.mobile.application
mongoQuery.disconnect();
break;
case MongoQueryEvent.MONGO_INSERT:
- mongoQuery.Insert(event.documents)
- break;
+ mongoQuery.insert(event.documents)
+ break;
+ case MongoQueryEvent.MONGO_DELETE:
+ mongoQuery.deleteDoc(event.documents);
+ break;
+ case MongoQueryEvent.MONGO_UDATE:
+ mongoQuery.update(event.documents);
+ break;
default:
// should never get here
View
19 src/com/kdata/mobile/application/MongoQueryEvent.as
@@ -14,6 +14,8 @@ package com.kdata.mobile.application
public static const MONGO_LOGIN_FAULT : String = "mongoLoginFault";
public static const MONGO_DISCONNECT : String = "mongoDisconnect";
public static const MONGO_INSERT : String = "mongoInsert";
+ public static const MONGO_DELETE : String = "mongoDelete";
+ public static const MONGO_UDATE : String = "mongoUpdate";
public var result : ArrayCollection;
public var documents : Array;
@@ -83,5 +85,22 @@ package com.kdata.mobile.application
public static function getMongoInsert(document:Array) : MongoQueryEvent {
return new MongoQueryEvent( MONGO_INSERT, null,document );
}
+
+ /**
+ * @brief Produce a MongoQueryEvent
+ * @return A MongoQueryEvent
+ */
+ public static function getMongoDelete(document:Array) : MongoQueryEvent {
+ return new MongoQueryEvent( MONGO_DELETE, null,document );
+ }
+
+
+ /**
+ * @brief Produce a MongoQueryEvent
+ * @return A MongoQueryEvent
+ */
+ public static function getMongoUpdate(document:Array) : MongoQueryEvent {
+ return new MongoQueryEvent( MONGO_UDATE, null,document );
+ }
}
}
View
18 src/com/kdata/mobile/infrastructure/MongoQuery.as
@@ -65,12 +65,26 @@ package com.kdata.mobile.infrastructure
}
/**
- * @brief connect to the database
+ * @brief insert to the database
*/
- public function Insert(documents:Array) : void
+ public function insert(documents:Array) : void
{
db.getCollection(mongoConfig.dbCollection).insert(documents);
}
+ /**
+ * @brief delete to the database
+ */
+ public function deleteDoc(documents:Array) : void
+ {
+ db.getCollection(mongoConfig.dbCollection).deleteDoc(documents);
+ }
+
+ public function update(documents:Array) : void
+ {
+ db.getCollection(mongoConfig.dbCollection).update(documents);
+ }
+
+
}
}
View
36 src/com/kdata/mobile/presentation/ButtonMobileSkin.mxml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:s="library://ns.adobe.com/flex/spark">
+ <!-- host component -->
+ <fx:Metadata>
+ [HostComponent("spark.components.Button")]
+ </fx:Metadata>
+
+ <!-- states -->
+ <s:states>
+ <s:State name="disabled" />
+ <s:State name="down" />
+ <s:State name="over" />
+ <s:State name="up" />
+ </s:states>
+
+ <s:Rect top="0" right="0" bottom="0" left="0">
+ <s:fill>
+ <s:LinearGradient rotation="90">
+ <s:GradientEntry alpha="1" color="#FFFFFF" ratio="0" />
+ <s:GradientEntry alpha="1" color="#666666" ratio="1" />
+ </s:LinearGradient>
+ </s:fill>
+ </s:Rect>
+
+ <!-- SkinParts
+ name=iconDisplay, type=spark.primitives.BitmapImage, required=false
+ name=labelDisplay, type=spark.core.IDisplayText, required=false
+ -->
+
+ <s:Label id="labelDisplay" verticalAlign="middle" textAlign="center" left="5" fontSize="24"
+ verticalCenter="1" horizontalCenter="1" fontWeight="bold" color="#FFFFFF">
+
+ </s:Label>
+
+</s:Skin>
View
7 src/com/kdata/mobile/presentation/MAMAbout.mxml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:s="library://ns.adobe.com/flex/spark" title="MAMAbout">
+ <fx:Declarations>
+ <!-- Place non-visual elements (e.g., services, value objects) here -->
+ </fx:Declarations>
+</s:View>
View
84 src/com/kdata/mobile/presentation/MAMHomeView.mxml
@@ -80,36 +80,56 @@
]]>
</fx:Script>
- <s:Scroller width="100%" height="100%">
- <s:Group width="100%" height="100%">
- <s:Form id="form" x="0" top="0" width="100%" height="100%">
- <s:FormHeading label="Connection info"/>
- <s:FormItem label="Name">
- <s:TextInput id="txtServerName" text="{config.name}" width="150" />
- </s:FormItem>
- <s:FormItem label="Host">
- <s:TextInput id="txtServerAdress" text="{config.dbHost}" width="150" />
- </s:FormItem>
- <s:FormItem label="Port">
- <s:TextInput id="txtServerPort" text="{config.dbPort}" width="150" />
- </s:FormItem>
- <s:FormItem label="DBName">
- <s:TextInput id="txtServerDBName" text="{config.dbName}" width="150" />
- </s:FormItem>
- <s:FormItem label="UserName">
- <s:TextInput id="txtServerUserName" text="{config.dbUser}" width="150" />
- </s:FormItem>
- <s:FormItem label="Password">
- <s:TextInput id="txtServerPassword" text="{config.dbPassword}" width="150" />
- </s:FormItem>
- <s:HGroup width="100%">
- <s:Button id="btnConnect" label="Connect" click="login()" width="100%" />
- <s:Button label="Save" width="100%" click="saveHost()" />
- <s:Button label="New" width="100%" click="clear()"/>
- </s:HGroup>
- </s:Form>
- </s:Group>
- </s:Scroller>
-
-
+ <s:VGroup width="100%" height="100%" gap="0">
+ <s:Scroller width="100%" height="100%">
+ <s:Group width="100%" height="100%">
+ <s:Form id="form" left="2" right="2" top="0" height="100%">
+ <s:FormHeading label="Connection info"/>
+ <s:FormItem label="Name" width="100%" left="2">
+ <s:layout>
+ <s:HorizontalLayout paddingRight="5" variableColumnWidth="true"/>
+ </s:layout>
+ <s:TextInput id="txtServerName" right="5" width="100%" paddingRight="2"
+ text="{config.name}"/>
+ </s:FormItem>
+ <s:FormItem label="Host" width="100%">
+ <s:layout>
+ <s:HorizontalLayout paddingRight="5" variableColumnWidth="true"/>
+ </s:layout>
+ <s:TextInput id="txtServerAdress" text="{config.dbHost}" width="100%" />
+ </s:FormItem>
+ <s:FormItem width="100%" label="Port">
+ <s:layout>
+ <s:HorizontalLayout paddingRight="5" variableColumnWidth="true"/>
+ </s:layout>
+ <s:TextInput id="txtServerPort" text="{config.dbPort}" width="100%" />
+ </s:FormItem>
+ <s:FormItem width="100%" label="DBName">
+ <s:layout>
+ <s:HorizontalLayout paddingRight="5" variableColumnWidth="true"/>
+ </s:layout>
+ <s:TextInput id="txtServerDBName" text="{config.dbName}" width="100%" />
+ </s:FormItem>
+ <s:FormItem width="100%" label="UserName">
+ <s:layout>
+ <s:HorizontalLayout paddingRight="5" variableColumnWidth="true"/>
+ </s:layout>
+ <s:TextInput id="txtServerUserName" text="{config.dbUser}" width="100%" />
+ </s:FormItem>
+ <s:FormItem width="100%" label="Password">
+ <s:layout>
+ <s:HorizontalLayout paddingRight="5" variableColumnWidth="true"/>
+ </s:layout>
+ <s:TextInput id="txtServerPassword" text="{config.dbPassword}" width="100%" />
+ </s:FormItem>
+ </s:Form>
+ </s:Group>
+ </s:Scroller>
+
+ <s:HGroup bottom="-1" width="100%" gap="1" height="12%">
+ <s:Button skinClass="com.kdata.mobile.presentation.ButtonMobileSkin" label="Connect" click="login()" width="100%" height="100%" />
+ <s:Button skinClass="com.kdata.mobile.presentation.ButtonMobileSkin" label="Save" click="saveHost()" width="100%" height="100%" />
+ <s:Button skinClass="com.kdata.mobile.presentation.ButtonMobileSkin" label="New" click="clear()" width="100%" height="100%" />
+ </s:HGroup>
+ </s:VGroup>
</s:View>
View
85 src/com/kdata/mobile/presentation/MAMInsert.mxml
@@ -1,26 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="MAMInsert"
- xmlns:parsley="http://www.spicefactory.org/parsley">
+ xmlns:parsley="http://www.spicefactory.org/parsley"
+ creationComplete="init()">
<fx:Script>
<![CDATA[
import com.kdata.mobile.application.MongoQueryEvent;
+ import mx.events.FlexEvent;
+
import org.db.mongo.Document;
+ import org.serialization.bson.ObjectID;
+
+
[MessageDispatcher] public var dispatchMessage : Function;
- protected function insert():void
+ private function init():void
+ {
+ if(data)
+ {
+ txiNome.text = data.nome;
+ cekPref.selected=data.preferred;
+ currentState="updateState";
+ }
+ else
+ currentState="insertState";
+ }
+
+
+ private function insert():void
{
var doc:Document = new Document();
doc.put("nome",txiNome.text);
+ doc.put("preferred",cekPref.selected);
var arr:Array = new Array(doc);
dispatchMessage(MongoQueryEvent.getMongoInsert(arr));
+ navigator.popView();
+ }
+
+ private function update():void
+ {
+ var doc:Document = new Document();
+ doc.put("_id",data._id);
+ doc.put("nome",txiNome.text);
+ doc.put("preferred",cekPref.selected);
+ var arr:Array = new Array(doc);
+ dispatchMessage(MongoQueryEvent.getMongoUpdate(arr));
+ navigator.popView();
}
+
+ private function deleteItem():void
+ {
+ var doc:Document = new Document();
+ doc.put("_id",data._id);
+ var arr:Array = new Array(doc);
+ dispatchMessage(MongoQueryEvent.getMongoDelete(arr));
+ navigator.popView();
+ }
+
]]>
</fx:Script>
+ <s:states>
+ <s:State name="insertState"/>
+ <s:State name="updateState"/>
+ </s:states>
<fx:Declarations>
<parsley:Configure />
@@ -29,11 +75,40 @@
<s:navigationContent>
<s:Button icon="@Embed('assets/back.png')" click="navigator.popView()"/>
</s:navigationContent>
- <s:TextInput id="txiNome" left="10" top="20" prompt="Nome"/>
- <s:Button right="10" top="80" label="Insert" click="insert()"/>
-
+ <s:Group width="100%" height="100%">
+ <s:VGroup top="10" width="100%" height="100%" gap="10">
+ <s:HGroup width="100%" horizontalAlign="center"
+ paddingBottom.insertState="5" paddingTop.insertState="5">
+ <s:TextInput id="txiNome" prompt="Nome"/>
+ </s:HGroup>
+
+
+ <s:HGroup width="100%" horizontalAlign="left" paddingLeft="40" verticalAlign="middle"
+ paddingBottom.insertState="5" paddingTop.insertState="5">
+ <s:Label left="20" top="80" width="120" height="20" color="#FF0000" fontSize="22"
+ fontStyle="normal" fontWeight="bold" text="Preferred : " textAlign="left"
+ textDecoration="none" verticalAlign="middle"/>
+ <s:CheckBox id="cekPref" left="150" top="72"/>
+ </s:HGroup>
+
+
+ </s:VGroup>
+
+
+ <s:HGroup bottom="-1" width="100%" gap="1" height="12%">
+ <s:Button skinClass="com.kdata.mobile.presentation.ButtonMobileSkin" width="100%" height="100%"
+ label="Delete" click="deleteItem()" includeIn="updateState"/>
+ <s:Button skinClass="com.kdata.mobile.presentation.ButtonMobileSkin" width="100%" height="100%"
+ label="Update" click="update()" includeIn="updateState"/>
+ <s:Button skinClass="com.kdata.mobile.presentation.ButtonMobileSkin" width="100%" height="100%"
+ label="Insert" click="insert()" includeIn="insertState"/>
+ </s:HGroup>
+
+ </s:Group>
+
+
</s:View>
View
6 src/com/kdata/mobile/presentation/MAMSettings.mxml
@@ -36,7 +36,11 @@
change="loadServer()">
<s:itemRenderer>
<fx:Component>
- <s:IconItemRenderer label="{data.name}"/>
+ <s:IconItemRenderer label="{data.name}" decorator="@Embed('assets/back.png')">
+ <s:iconPlaceholder>
+
+ </s:iconPlaceholder>
+ </s:IconItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
View
34 src/com/kdata/mobile/presentation/MobileActionMongoHome.mxml
@@ -26,15 +26,29 @@
</s:navigationContent>
- <s:Button right="70" top="20" label="New Insert" click="navigator.pushView(MAMInsert)"/>
- <s:List id="listConn" top="100" bottom="0" left="0" right="0"
- dataProvider="{model.documents}">
- <s:itemRenderer>
- <fx:Component>
- <s:IconItemRenderer label="{data.nome}">
- </s:IconItemRenderer>
+ <s:VGroup width="100%" height="100%" gap="0">
+ <s:VGroup width="100%" height="100%" gap="0">
+ <s:List id="listConn" dataProvider="{model.documents}" width="100%" height="100%"
+ change="navigator.pushView(MAMInsert,listConn.selectedItem)">
+ <s:itemRenderer>
+ <fx:Component>
+ <s:IconItemRenderer label="{data.nome}">
+ </s:IconItemRenderer>
+
+ </fx:Component>
+ </s:itemRenderer>
+ </s:List>
+ </s:VGroup>
+ <s:HGroup bottom="-1" width="100%" gap="1" height="12%">
+ <s:Button skinClass="com.kdata.mobile.presentation.ButtonMobileSkin" width="100%" height="100%"
+ label="New Insert" click="navigator.pushView(MAMInsert)"/>
+ </s:HGroup>
+
+ </s:VGroup>
+
+
+
+
+
- </fx:Component>
- </s:itemRenderer>
- </s:List>
</s:View>
Please sign in to comment.
Something went wrong with that request. Please try again.