Commit 01496da5 authored by François Billioud's avatar François Billioud

start fixing DocumentList initialization

parent b05705a5
...@@ -29,7 +29,7 @@ var Page = { ...@@ -29,7 +29,7 @@ var Page = {
this.loadXML("xml/"+page+".xml"); this.loadXML("xml/"+page+".xml");
} else { } else {
//display user information when the storage is ready //display user information when the storage is ready
if (Storage[Storage.USER_READY]) { if (Storage.user) {
Page.displayUserInformation(getCurrentUser()); Page.displayUserInformation(getCurrentUser());
DocumentList.initialize(); DocumentList.initialize();
} else { } else {
...@@ -40,11 +40,16 @@ var Page = { ...@@ -40,11 +40,16 @@ var Page = {
} }
//display the document list when the line factory is ready //display the document list when the line factory is ready
Line.loadHTML(function() { Line.loadHTML(function() {
if (Storage[Storage.LIST_READY]) { var list = getCurrentDocumentList();
getCurrentDocumentList().display(); if (list && list.detailedList) {
list.display();
list.resetSelectionList();
resize();
} else { } else {
Storage.addEventHandler(function() { Storage.addEventHandler(function() {
getCurrentDocumentList().display(); list.display();
list.resetSelectionList();
resize();
},Storage.LIST_READY); },Storage.LIST_READY);
} }
}); });
...@@ -227,7 +232,7 @@ Storage.load({ ...@@ -227,7 +232,7 @@ Storage.load({
user.setName(jioFileContent.userName); user.setName(jioFileContent.userName);
storage.user = user; storage.user = user;
storage.userName = storage.user.getName(); storage.userName = storage.user.getName();
storage.user.storageLocation = jioFileContent.location;debugger; storage.user.storageLocation = jioFileContent.location;
storage.save(function() {storage.fireEvent(Storage.STORAGE_CREATED);}); storage.save(function() {storage.fireEvent(Storage.STORAGE_CREATED);});
} }
}, },
...@@ -243,10 +248,12 @@ Storage.load({ ...@@ -243,10 +248,12 @@ Storage.load({
var dataStorage = JSON.parse(localStorage.getItem("currentStorage")); var dataStorage = JSON.parse(localStorage.getItem("currentStorage"));
if(!dataStorage) {window.location.href = "login.html";}//if it's the first connexion if(!dataStorage) {window.location.href = "login.html";}//if it's the first connexion
this.jio = JIO.initialize(dataStorage.jio.jioFileContent, {"ID":"www.ungproject.com"}); this.jio = dataStorage.jio;
JIO.initialize(dataStorage.jio, {"ID":"www.ungproject.com"});
Storage.currentStorage = this; Storage.currentStorage = this;
this.setUser(new User(dataStorage.user)); //wait for JIO being ready
JIO.ready(function(){Storage.setUser(new User(dataStorage.user))});
}, },
USER_READY: "userReady", // value of the USER_READY event USER_READY: "userReady", // value of the USER_READY event
LIST_READY: "listReady", // value of the LIST_READY event LIST_READY: "listReady", // value of the LIST_READY event
...@@ -304,7 +311,6 @@ Storage.load({ ...@@ -304,7 +311,6 @@ Storage.load({
user:Storage.user, user:Storage.user,
userName:Storage.userName userName:Storage.userName
} }
debugger;
localStorage.currentStorage = JSON.stringify(storage); localStorage.currentStorage = JSON.stringify(storage);
if(instruction) {instruction();} if(instruction) {instruction();}
}); });
......
...@@ -271,7 +271,7 @@ Line.getOriginalHTML = function() {return Line.originalHTML;} ...@@ -271,7 +271,7 @@ Line.getOriginalHTML = function() {return Line.originalHTML;}
var createNewDocument = function(type) { var createNewDocument = function(type) {
var newDocument = new JSONDocument(); var newDocument = new JSONDocument();
newDocument.setType(type); newDocument.setType(type);
var fileName = DOcument.getAddress(newDocument); var fileName = Document.getAddress(newDocument);
newDocument.save(function() { newDocument.save(function() {
getDocumentList()[fileName]=newDocument; getDocumentList()[fileName]=newDocument;
......
...@@ -43,13 +43,8 @@ ...@@ -43,13 +43,8 @@
delete localStorage.currentDocumentID; delete localStorage.currentDocumentID;
getCurrentStorage().save(); getCurrentStorage().save();
} }
Line.loadHTML(//display the list of documents resize();
function() {
getDocumentList().resetSelectionList();
getDocumentList().display();
resize();
}
);
} }
$(window).resize(resize); $(window).resize(resize);
$(document).ready(init); $(document).ready(init);
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
default:alert("Error while getting jio.json content");break; default:alert("Error while getting jio.json content");break;
} }
this.storage = createStorage(JSON.parse( this.jioFileContent ), applicant);//create the object allowing IO in storages this.storage = createStorage(JSON.parse( this.jioFileContent ), applicant);//create the object allowing IO in storages
this.ready();
} }
}, },
...@@ -48,6 +49,8 @@ ...@@ -48,6 +49,8 @@
*/ */
isReady: function() {return this.jioFileContent && this.storage}, isReady: function() {return this.jioFileContent && this.storage},
ready: function(instruction) {this.ready = instruction},
//IO functions //IO functions
getLocation: function() {return this.location}, getLocation: function() {return this.location},
userNameAvailable: function(name, option) { userNameAvailable: function(name, option) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment