Skip to content

Commit

Permalink
updated the demo with the last version of joli.js
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierlacot committed Nov 28, 2011
1 parent c579a63 commit 51ad786
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
.project
build/android/*
build/iphone/*
tmp
11 changes: 10 additions & 1 deletion Resources/app.js
@@ -1,6 +1,14 @@
var joli, joli2;

(function() {
// load joli library and models definition file
// load joli library using Ti.include()
Ti.include('/lib/vendor/joli.js/joli.js');
joli.connection = new joli.Connection('joli-js-demo');

// load joli library using Ti.include()
joli2 = require('lib/vendor/joli.js/joli').connect('joli-js-demo-2');

// load the models definition file
Ti.include('/lib/model/models.js');

// load jasmine library and adapter
Expand All @@ -9,6 +17,7 @@

// initialize the model
joli.models.initialize();
joli2.models.initialize();

// load test facility functions
Ti.include('/test/main.js');
Expand Down
43 changes: 41 additions & 2 deletions Resources/lib/model/models.js
@@ -1,5 +1,3 @@
joli.connection = new joli.Connection('joli-js-demo');

var models = (function() {
var m = {};

Expand Down Expand Up @@ -69,5 +67,46 @@ var models = (function() {
}
});

return m;
})();



/**
* These tables are created in the joli2 database.
* We do not name this bag of models, so the only way to access them will be
* joli2.models.get()
*/
(function() {
var m = {};

m.human = new joli2.model({
table: 'human',
columns: {
id: 'INTEGER PRIMARY KEY AUTOINCREMENT',
city_id: 'INTEGER',
first_name: 'TEXT',
last_name: 'TEXT'
}
});

m.city = new joli2.model({
table: 'city',
columns: {
id: 'INTEGER PRIMARY KEY AUTOINCREMENT',
country_id: 'INTEGER',
name: 'TEXT',
description: 'TEXT'
}
});

m.country = new joli2.model({
table: 'country',
columns: {
id: 'INTEGER PRIMARY KEY AUTOINCREMENT',
name: 'TEXT'
}
});

return m;
})();
24 changes: 24 additions & 0 deletions Resources/test/main.js
Expand Up @@ -10,6 +10,11 @@ joliTest.prototype = {
models.city.truncate();
models.country.truncate();
models.human.truncate();

// also clear the second database
joli2.models.get('city').truncate();
joli2.models.get('country').truncate();
joli2.models.get('human').truncate();
},

/**
Expand All @@ -33,6 +38,25 @@ joliTest.prototype = {
this.sarah.save();
},

/**
* Insert some human records in the joli2 database
*/
createHumansInJoli2: function() {
// create a "human" record (persisted)
this.john2 = joli2.models.get('human').newRecord({
first_name: 'John',
last_name: 'Doe'
});
this.john2.save();

// create an other "human" record (persisted)
this.sarah2 = joli2.models.get('human').newRecord({
first_name: 'Sarah',
last_name: 'Sure'
});
this.sarah2.save();
},

/**
* Insert many human records
*/
Expand Down
5 changes: 5 additions & 0 deletions Resources/test/model.js
Expand Up @@ -32,7 +32,12 @@

it('joli.model.count()', function() {
test.createHumans();
test.createHumansInJoli2();
expect(models.human.count()).toBe(1);

// the same test, but accessing the model through joli.models.get()
expect(joli.models.get('human').count()).toBe(1);
expect(joli2.models.get('human').count()).toBe(2);
});

it('joli.model.deleteRecords()', function() {
Expand Down
4 changes: 2 additions & 2 deletions bin/titanium.sh
Expand Up @@ -6,8 +6,8 @@
PROJECT_NAME=${PROJECT_NAME}
PROJECT_ROOT=${PROJECT_ROOT:-../}
APP_DEVICE=${DEVICE_TYPE}
IPHONE_SDK_VERSION="4.3"
TI_SDK_VERSION="1.7.2"
IPHONE_SDK_VERSION="5.0"
TI_SDK_VERSION="1.7.5"
TI_DIR="/Library/Application\ Support/Titanium"
TI_ASSETS_DIR="${TI_DIR}/mobilesdk/osx/${TI_SDK_VERSION}"
TI_IPHONE_DIR="${TI_ASSETS_DIR}/iphone"
Expand Down
53 changes: 29 additions & 24 deletions tiapp.xml
@@ -1,34 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
<id>com.jolijs.demo</id>
<name>joliDemo</name>
<version>1.0</version>
<publisher>xavier</publisher>
<url>http://lacot.org/</url>
<description>No description provided</description>
<copyright>2011 by xavier</copyright>
<icon>default_app_logo.png</icon>
<deployment-targets>
<target device="mobileweb">true</target>
<target device="iphone">true</target>
<target device="ipad">true</target>
<target device="blackberry">false</target>
<target device="android">true</target>
</deployment-targets>
<id>com.jolijs.demo</id>
<name>joliDemo</name>
<version>1.0</version>
<publisher>xavier</publisher>
<url>http://lacot.org/</url>
<description>No description provided</description>
<copyright>2011 by xavier</copyright>
<icon>default_app_logo.png</icon>
<persistent-wifi>false</persistent-wifi>
<prerendered-icon>false</prerendered-icon>
<statusbar-style>default</statusbar-style>
<statusbar-hidden>false</statusbar-hidden>
<fullscreen>false</fullscreen>
<navbar-hidden>false</navbar-hidden>
<analytics>true</analytics>
<guid>53f55927-68cb-4e07-b056-83d5c7d04800</guid>
<iphone>
<orientations device="iphone">
<orientation>Ti.UI.PORTRAIT</orientation>
</orientations>
<orientations device="ipad">
<orientation>Ti.UI.PORTRAIT</orientation>
<orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
<orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
<orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
</orientations>
</iphone>
<android xmlns:android="http://schemas.android.com/apk/res/android">
</android>
<modules>
</modules>
<guid>53f55927-68cb-4e07-b056-83d5c7d04800</guid>
<iphone>
<orientations device="iphone">
<orientation>Ti.UI.PORTRAIT</orientation>
</orientations>
<orientations device="ipad">
<orientation>Ti.UI.PORTRAIT</orientation>
<orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
<orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
<orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
</orientations>
</iphone>
<android xmlns:android="http://schemas.android.com/apk/res/android"/>
<modules/>
</ti:app>

0 comments on commit 51ad786

Please sign in to comment.