Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
New class for loading React component inside standard Dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Feb 17, 2016
1 parent bd12f3e commit e1c2837
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/src/plugins/gui.ajax/res/js/ajaxplorer_ui.txt
Expand Up @@ -60,4 +60,5 @@ js/ui/prototype/class.DataModelProperty.js
js/ui/prototype/class.MultiDownloader.js
js/ui/prototype/class.ActivityMonitor.js
js/ui/prototype/class.AjxpReactComponent.js
js/ui/prototype/class.AjxpReactDialogLoader.js
js/ui/prototype/class.PydioUI.js
@@ -0,0 +1,100 @@
/*
* Copyright 2007-2015 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/

/**
* Simple Wrapper for React Component
*/
Class.create('AjxpReactDialogLoader', AjxpPane, {

reactComponent:null,
componentNamespace: null,
componentName: null,
options: null,
rootNodeId:null,

initialize: function(componentNamespace, componentName, options){
this.componentNamespace = componentNamespace;
this.componentName = componentName;
this.options = options;
if(!this.options) this.options = {};
this.options.pydio = pydio;
},

/**
*
* @param sFormId
* @param bSkipButtons
* @param bOkButtonOnly
* @param bUseNextButton
*/
openDialog: function(sFormId, bSkipButtons, bOkButtonOnly, bUseNextButton){
this.rootNodeId = sFormId;
modal.showDialogForm('Get',
sFormId,
this.dialogLoaded.bind(this),
this.submit.bind(this),
this.dialogWillClose.bind(this),
bOkButtonOnly,
bSkipButtons,
bUseNextButton
);
},

cancel: function(oForm){
console.log('cancel');

},

submit: function(oForm){
console.log('submit');

},

dismiss: function(oForm){
this.dialogWillClose(oForm);
hideLightBox();
},

dialogLoaded: function(oForm){

this.options.closeAjxpDialog = function(){
this.dismiss(oForm);
}.bind(this);

var namespacesToLoad = [this.componentNamespace];
if(this.options.dependencies){
this.options.dependencies.forEach(function(d){
namespacesToLoad.push(d);
});
}
ResourcesManager.loadClassesAndApply(namespacesToLoad, function(){
this.reactComponent = React.render(
React.createElement(window[this.componentNamespace][this.componentName], this.options),
oForm.down('#'+this.rootNodeId));
}.bind(this));
},

dialogWillClose: function(oForm){
console.log('close');
this.reactComponent = null;
React.unmountComponentAtNode(oForm.down('#'+this.rootNodeId));
}

});

0 comments on commit e1c2837

Please sign in to comment.