From 9140a5bb6e7ecc24e6b4e540308042e10165e604 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 9 Feb 2012 11:07:10 -0800 Subject: New File Adding new file functionality, awaiting UI to implement correct file path for templates to hook into mediator. --- js/io/system/coreioapi.js | 3 +++ js/io/system/fileio.js | 17 +++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'js/io/system') diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index bdba5240..d9505cd6 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js @@ -92,6 +92,9 @@ exports.CoreIoApi = Montage.create(Component, { //TODO: Remove test //this.ninjaLibrary.copyLibToCloud('Users/kgq387/Desktop/Ninja Cloud/Disk', 'montage0.6.0'); //this.ninjaLibrary.deleteLibraries(); + window.hack = function (name, type) { + this.application.ninja.ioMediator.fileNew('Users/kgq387/Desktop/Ninja Cloud/Disk/'+name+'.'+type, '/js/io/templates/files/'+type+'.txt', function (status) {console.log(status)}); + }.bind(this); } }, //////////////////////////////////////////////////////////////////// diff --git a/js/io/system/fileio.js b/js/io/system/fileio.js index 2c49e849..7bf4d41f 100755 --- a/js/io/system/fileio.js +++ b/js/io/system/fileio.js @@ -17,15 +17,13 @@ NOTES: //////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// */ // -var Montage = require("montage/core/core").Montage; +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component; //////////////////////////////////////////////////////////////////////// //Exporting as File I/O -exports.FileIo = Montage.create(Object.prototype, { +exports.FileIo = Montage.create(Component, { //////////////////////////////////////////////////////////////////// //newFile Object (*required): {uri*, contents, contentType} - //Return codes - // 204: File exists | 400: File exists | 404: File does not exists - // 201: File succesfully created | 500: Unknown | undefined: Unknown newFile: { enumerable: true, value: function(file) { @@ -35,7 +33,7 @@ exports.FileIo = Montage.create(Object.prototype, { return null; } //Peforming check for file to exist - var check = this.application.ninja.coreIoApi.fileExists(file.uri), status, create; + var check = this.application.ninja.coreIoApi.fileExists({uri: file.uri}), status, create; //Upon successful check, handling results if (check.success) { //Handling status of check @@ -47,10 +45,7 @@ exports.FileIo = Montage.create(Object.prototype, { case 404: //File does not exists, ready to be created create = this.application.ninja.coreIoApi.createFile(file); - //Storing status to be returned (for UI handling) - if (create.success) { - status = check.status; - } + status = create.status; break; default: //Unknown Error @@ -61,6 +56,8 @@ exports.FileIo = Montage.create(Object.prototype, { } //Returning resulting code return status; + // 204: File exists | 400: File exists | 404: File does not exists + // 201: File succesfully created | 500: Unknown | undefined: Unknown } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3