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

Commit

Permalink
Inbox : replace left panel by a quick filter box
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Mar 10, 2016
1 parent d5c6557 commit 43b85e2
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 7 deletions.
8 changes: 4 additions & 4 deletions core/src/plugins/access.inbox/Gruntfile.js
Expand Up @@ -7,9 +7,9 @@ module.exports = function(grunt) {
files: [
{
expand: true,
cwd: 'res/',
src: ['**/*.es6'],
dest: 'res/',
cwd: 'res/react',
src: ['**/*.js'],
dest: 'res/build',
ext: '.js'
}
]
Expand All @@ -18,7 +18,7 @@ module.exports = function(grunt) {
watch: {
js: {
files: [
"res/*.es6"
"res/react/*.js"
],
tasks: ['babel'],
options: {
Expand Down
8 changes: 6 additions & 2 deletions core/src/plugins/access.inbox/manifest.xml
Expand Up @@ -3,7 +3,7 @@
<class_definition filename="plugins/access.inbox/class.inboxAccessDriver.php" classname="inboxAccessDriver"/>
<client_settings>
<resources>
<js file="plugins/access.inbox/res/InboxCellModifier.js" className="InboxCellModifier"/>
<js file="plugins/access.inbox/res/build/InboxWidgets.js" className="InboxWidgets"/>
<css file="plugins/access.inbox/res/inbox_style.css"/>
</resources>
</client_settings>
Expand Down Expand Up @@ -85,10 +85,14 @@
<client_configs>
<component_config className="FilesList">
<columns>
<additional_column attributeName="share_meta_type" sortType="CellSorterValue" modifier="InboxCellModifier.updateCell" defaultVisibilty="visible" messageString="Share Type"/>
<additional_column attributeName="share_meta_type" sortType="CellSorterValue" modifier="InboxWidgets.filesListCellModifier"
defaultVisibilty="visible" messageString="Share Type"/>
</columns>
</component_config>
</client_configs>
<client_configs>
<template_part ajxpClass="AjxpReactComponent" ajxpId="topPane" ajxpOptions='{"componentNamespace":"InboxWidgets","componentName":"LeftPanel"}'/>
</client_configs>
</registry_contributions>
<dependencies>
<pluginClass pluginName="access.fs"/>
Expand Down
60 changes: 59 additions & 1 deletion core/src/plugins/access.inbox/res/inbox_style.css
Expand Up @@ -6,4 +6,62 @@

.share_meta_type_2 .thumbLabel{
color: rgba(236, 16, 16, 0.75);
}
}

div.inbox-left-panel{
font-size: 13px;
padding: 16px;
color: white;
font-family: Roboto, sans-serif;
-webkit-font-smoothing: antialiased;
}

div.inbox-left-panel input{
margin-left:0;
box-sizing: border-box;
border-radius: 2px;
width: 100%;
border: 0;
font-size: 14px;
padding: 4px 8px;

}

#browser #topPane div.inbox-left-panel h3{
padding: 0 0 20px 0;
font-size: 14px;
}

#browser #topPane div.inbox-left-panel h4{
margin: 30px 0 5px;
}

#browser #topPane div.inbox-left-panel h5{
margin: 0;
font-size: 13px;
font-weight: 500;
}

#browser #topPane div.inbox-left-panel h5 span.clear {
background-color: transparent;
color: white;
float: right;
cursor: pointer;
color:rgba(255,255,255,0.5);
}

#browser #topPane div.inbox-left-panel span.share_meta_filter{
display: inline-block;
padding: 5px 10px;
margin: 4px 8px 4px 0;
color: rgba(0,0,0,0.87);
background-color: white;
border-radius: 2px;
text-transform: uppercase;
font-weight: 500;
cursor: pointer;
font-size: 14px;
}
#browser #topPane div.inbox-left-panel span.share_meta_filter.active{
background-color: #cccccc;
}
109 changes: 109 additions & 0 deletions core/src/plugins/access.inbox/res/react/InboxWidgets.js
@@ -0,0 +1,109 @@
(function(global){

var ns = global.InboxWidgets ||{};

var LeftPanel = React.createClass({

propTypes:{
pydio:React.PropTypes.instanceOf(Pydio)
},

getInitialState:function(){
return {meta_filter:null};
},

handleChange: function(event) {
var value = event.target.value;
if(value) value += '*';
document.getElementById('content_pane').ajxpPaneObject.addMetadataFilter('text', value);
},

focus:function(){
this.props.pydio.UI.disableAllKeyBindings();
},
blur:function(){
this.props.pydio.UI.enableAllKeyBindings();
},
filterByShareMetaType(type, event){
if(type == '-1'){
type = '';
}
this.setState({meta_filter:type});
document.getElementById('content_pane').ajxpPaneObject.addMetadataFilter('share_meta_type', type);
},

render: function(){
return (
<div className="inbox-left-panel">
<h3 className="colorcode-folder">Files shared with me</h3>
<div>These are the standalone files that people have shared with you. Folders are accessible directly via the left panel.</div>
<h4>Quick Filtering</h4>
<div>
<h5>By file name</h5>
<input type="text" placeholder="Filter..." onChange={this.handleChange} onFocus={this.focus} onBlur={this.blur}/>
</div>
<div style={{paddingTop:20}}>
<h5><span className="clear" onClick={this.filterByShareMetaType.bind(this, '-1')}>Clear</span>
By type
</h5>
<span className={(this.state.meta_filter === '0'?'active':'') + " share_meta_filter"} onClick={this.filterByShareMetaType.bind(this, '0')}>Invitations</span>
<span className={(this.state.meta_filter === '1'?'active':'') + " share_meta_filter"} onClick={this.filterByShareMetaType.bind(this, '1')}>Shares</span>
<span className={(this.state.meta_filter === '2'?'active':'') + " share_meta_filter"} onClick={this.filterByShareMetaType.bind(this, '2')}>Errors</span>
</div>
</div>
);
}

});


function filesListCellModifier(element, ajxpNode, type, metadataDef, ajxpNodeObject){

if(element != null){
var nodeMetaValue = ajxpNode.getMetadata().get('share_meta_type');
var nodeMetaLabel;
if(nodeMetaValue == "0") nodeMetaLabel = "Invitation";
else if(nodeMetaValue == "1") nodeMetaLabel = "Share";
else if(nodeMetaValue == "2") nodeMetaLabel = "Error";
if(element.down('.text_label')){
element.down('.text_label').update(nodeMetaLabel);
}
var mainElement;
if(element.up('.ajxpNodeProvider')){
mainElement = element.up('.ajxpNodeProvider');
}else if(ajxpNodeObject){
mainElement = ajxpNodeObject;
}else{
console.log(element, ajxpNodeObject);
}
if(mainElement){
mainElement.addClassName('share_meta_type_' + nodeMetaValue);
}

if(type == 'row'){
element.writeAttribute("data-sorter_value", nodeMetaValue);
}else{
element.writeAttribute("data-"+metadataDef.attributeName+"-sorter_value", nodeMetaValue);
}

var obj = document.getElementById('content_pane').ajxpPaneObject;
var colIndex;
obj.columnsDef.map(function(c, index){
if (c.attributeName == "share_meta_type") {
colIndex = index;
}
}.bind(this));
if(colIndex !== undefined){
obj._sortableTable.sort(colIndex, false);
obj._sortableTable.updateHeaderArrows();
}
}


}

ns.filesListCellModifier = filesListCellModifier;
ns.LeftPanel = LeftPanel;
global.InboxWidgets = ns;

})(window);

0 comments on commit 43b85e2

Please sign in to comment.