Skip to content
This repository has been archived by the owner on May 7, 2019. It is now read-only.

Commit

Permalink
DNN-9670 - Syntax update
Browse files Browse the repository at this point in the history
  • Loading branch information
pterenin committed May 3, 2017
1 parent 699b5f7 commit 2a382be
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 642 deletions.
10 changes: 10 additions & 0 deletions .eslintskipwords.js
Expand Up @@ -10,6 +10,7 @@ module.exports = [
"jwt",
"microservice",
"init",
"concat",
"http",
"stringify",
"tokenize",
Expand All @@ -21,10 +22,19 @@ module.exports = [
"microservices",
"ui",
"tooltip",
"interactor",
"comparator",
"shortid",
"br",
"svg",
"li",
"decendants",
"fns",
"unselect",
"fn",
"eslint",
"checkbox",
"const",
"socialpanelheader",
"socialpanelbody",
"searchpanel",
Expand Down
3 changes: 3 additions & 0 deletions TreeControlInteractor/index.js
@@ -0,0 +1,3 @@
"use strict"

module.exports = require("./lib/TreeControlInteractor");
4 changes: 2 additions & 2 deletions TreeControlInteractor/lib/TreeControlInteractor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion TreeControlInteractor/package.json
@@ -1,6 +1,6 @@
{
"name": "dnn-tree-control-interactor",
"version": "0.0.1",
"version": "0.0.4",
"description": "Renders are selectable stateful tree",
"main": "index.js",
"scripts": {
Expand Down
@@ -1,17 +1,15 @@
import React, { Component } from "react";
import { PropTypes } from "prop-types";
import { IconSelector } from "./icons/selector";
import { global } from "./_global";

import {IconSelector} from "./icons/IconSelector";
import {global} from "./global";

const styles = global.styles;
const floatLeft = styles.float();
const merge = styles.merge;


import "./styles.less";

export class TreeControl extends Component {
export default class TreeControl extends Component {

constructor(props) {
super(props);
Expand All @@ -25,19 +23,19 @@ export class TreeControl extends Component {

_traverse(comparator) {
let ChildTabs = this.props.tabs;
const cached_childtabs = [];
cached_childtabs.push(ChildTabs);
const condition = cached_childtabs.length > 0;
const cachedChildTabs = [];
cachedChildTabs.push(ChildTabs);
const condition = cachedChildTabs.length > 0;

const loop = () => {
const childtab = cached_childtabs.length ? cached_childtabs.shift() : null;
const left = () => childtab.forEach(tab => {
const childTab = cachedChildTabs.length ? cachedChildTabs.shift() : null;
const left = () => childTab.forEach(tab => {
Array.isArray(tab.ChildTabs) ? comparator(tab, this.props.tabs) : null;
Array.isArray(tab.ChildTabs) && tab.ChildTabs.length ? cached_childtabs.push(tab.ChildTabs) : null;
Array.isArray(tab.ChildTabs) && tab.ChildTabs.length ? cachedChildTabs.push(tab.ChildTabs) : null;
condition ? loop() : exit();
});
const right = () => null;
childtab ? left() : right();
childTab ? left() : right();
};

const exit = () => null;
Expand All @@ -62,19 +60,19 @@ export class TreeControl extends Component {

_mapToChildTabs(tab, fn) {
let ChildTabs = tab.ChildTabs;
const cached_childtabs = [];
cached_childtabs.push(ChildTabs);
const condition = cached_childtabs.length > 0;
const cachedChildTabs = [];
cachedChildTabs.push(ChildTabs);
const condition = cachedChildTabs.length > 0;

const loop = () => {
const childtab = cached_childtabs.length ? cached_childtabs.shift() : null;
const left = () => childtab.forEach(tab => {
const childTab = cachedChildTabs.length ? cachedChildTabs.shift() : null;
const left = () => childTab.forEach(tab => {
Array.isArray(tab.ChildTabs) ? fn(tab) : null;
Array.isArray(tab.ChildTabs) && tab.ChildTabs.length ? cached_childtabs.push(tab.ChildTabs) : null;
Array.isArray(tab.ChildTabs) && tab.ChildTabs.length ? cachedChildTabs.push(tab.ChildTabs) : null;
condition ? loop() : exit();
});
const right = () => null;
childtab ? left() : right();
childTab ? left() : right();
};
const exit = () => null;

Expand All @@ -95,10 +93,10 @@ export class TreeControl extends Component {
}

resetCheckedState(tab) {
const unselectChildren = (childtab) => {
childtab.CheckedState = this.props.unchecked;
childtab.ChildrenSelected = false;
this.props.updateTree(childtab);
const unselectChildren = (childTab) => {
childTab.CheckedState = this.props.unchecked;
childTab.ChildrenSelected = false;
this.props.updateTree(childTab);
};

const unselectIndividual = () => {
Expand Down Expand Up @@ -267,26 +265,21 @@ export class TreeControl extends Component {
render_li(tabs) {
const render = (() => {
return tabs.map(tab => {
const listStyle = styles.listStyle();
const textLeft = styles.textAlign("left");
const ULPadding = styles.padding({ all: 3 });
const spanPadLeft = styles.padding({ left: 5 });

const tabName = this.render_tabName(tab);
const checkbox = this.render_ListCheckbox(tab);
const bullet = this.render_ListBullet.call(this, tab, this.expandParent.bind(this, tab));
const tree = this.render_tree(tab.ChildTabs);
const anyChildrenSelected = (tab) => {
const ChildTabs = tab.ChildTabs;
const left = () => {
const truthyCheckedState = [];
const trueCheckedState = [];
const AreChildrenChecked = (t) => {
const condition = t.CheckedState !== this.props.unchecked;
condition ? truthyCheckedState.push(true) : truthyCheckedState.push(false);
condition ? trueCheckedState.push(true) : trueCheckedState.push(false);
};

this._mapToChildTabs(tab, AreChildrenChecked);
const bool = truthyCheckedState.indexOf(true) !== -1 ? true : false;
const bool = trueCheckedState.indexOf(true) !== -1 ? true : false;
return bool;
};
const right = () => null;
Expand Down Expand Up @@ -337,12 +330,7 @@ export class TreeControl extends Component {

render() {
const listStyle = styles.listStyle();
const textLeft = styles.textAlign("left");
const ULPadding = styles.padding({ all: 3 });
const spanPadLeft = styles.padding({ left: 5 });

const list_items = this.render_li(this.props.tabs);

return (
<ul className="page-picker" style={merge(listStyle)} >
{list_items}
Expand Down
@@ -1,28 +1,20 @@
import React, { Component } from "react";
import { PropTypes } from "prop-types";
import { TreeControl } from "./_treeControl";
import { IconSelector } from "./icons/selector";
import { global } from "./_global";

const styles = global.styles;
const floatLeft = styles.float();
const merge = styles.merge;

import TreeControl from "./TreeControl";
import {IconSelector} from "./icons/IconSelector";

import "./styles.less";

export class TreeControlInteractor extends Component {
export default class TreeControlInteractor extends Component {

constructor(props) {
super();
this.cached_ChildTabs;
this.cachedChildTabs;
this.icon = IconSelector("arrow_bullet");
this.PortalTabsParameters = props.PortalTabsParameters;

this.fullyChecked = 2;
this.individuallyChecked = 1;
this.unchecked = 0;

}

componentWillMount() {
Expand All @@ -47,8 +39,6 @@ export class TreeControlInteractor extends Component {

}



requestDescendantTabs(ParentTabId, callback) {

let descendantTabs = [];
Expand Down Expand Up @@ -116,48 +106,47 @@ export class TreeControlInteractor extends Component {
traverse(comparator) {
const copy = this.state.tabs;
let ChildTabs = copy;
const cached_childtabs = [];
cached_childtabs.push(ChildTabs);
const condition = cached_childtabs.length > 0;
const cachedChildTabs = [];
cachedChildTabs.push(ChildTabs);
const condition = cachedChildTabs.length > 0;

const loop = () => {
const childtab = cached_childtabs.length ? cached_childtabs.shift() : null;
const left = () => childtab.forEach(tab => {
const childTab = cachedChildTabs.length ? cachedChildTabs.shift() : null;
const left = () => childTab.forEach(tab => {
Array.isArray(tab.ChildTabs) ? comparator(tab, copy) : null;
Array.isArray(tab.ChildTabs) && tab.ChildTabs.length ? cached_childtabs.push(tab.ChildTabs) : null;
Array.isArray(tab.ChildTabs) && tab.ChildTabs.length ? cachedChildTabs.push(tab.ChildTabs) : null;
condition ? loop() : exit();
});
const right = () => null;
childtab ? left() : right();
childTab ? left() : right();
};

const exit = () => null;
loop();
return;
}

findParent(tabdata) {
findParent(tabData) {
let parent = {};
const capture = (tab) => {
parent = tab || {};
};
const find = (tab, copy) => {
const condition = parseInt(tab.TabId) === parseInt(tabdata.ParentTabId);
const find = (tab) => {
const condition = parseInt(tab.TabId) === parseInt(tabData.ParentTabId);
condition ? capture(tab) : null;
};
this.traverse(find);
return parent;
}

updateTree(tabdata) {
let updateTab = null;
updateTree(tabData) {
let newState = null;
const capture = (tab, copy) => {
tab = JSON.parse(JSON.stringify(tabdata));
tab = JSON.parse(JSON.stringify(tabData));
newState = copy;
};
const find = (tab, copy) => {
parseInt(tab.TabId) === parseInt(tabdata.TabId) ? capture(tab, copy) : null;
parseInt(tab.TabId) === parseInt(tabData.TabId) ? capture(tab, copy) : null;
};
this.traverse(find);
this.setState({ tabs: newState });
Expand All @@ -173,17 +162,12 @@ export class TreeControlInteractor extends Component {
const realign = (tab) => {
iterationsArray = [];
let sum = 0;
let newState = null;
const tabsWithChildren = [];
const tabsWithoutChildren = [];
const ChildTabs = tab.ChildTabs;

tab.ChildTabs.forEach((t) => {
t.HasChildren ? tabsWithChildren.push(t) : tabsWithoutChildren.push(t);
});

const expect = tabsWithoutChildren.length + tabsWithChildren.length * this.fullyChecked;

tabsWithoutChildren.forEach(t => {
t.CheckedState === this.individuallyChecked ? sum += 1 : null;
});
Expand Down Expand Up @@ -247,9 +231,7 @@ export class TreeControlInteractor extends Component {
children = filterOnlyChildren(tabs);
children = filterOutIfAllSelected(children, parents);
parents = filterOutIfAllSelected(parents, parents);

const exports = parents.concat(children);
console.log(exports);
this.props.OnSelect(exports);

}
Expand Down Expand Up @@ -278,7 +260,7 @@ export class TreeControlInteractor extends Component {
TreeControlInteractor.propTypes = {
PortalTabsParameters: PropTypes.object.isRequired,
OnSelect: PropTypes.func.isRequired,
PortalTabParamters: PropTypes.object.isRequired,
PortalTabParameters: PropTypes.object.isRequired,
getInitialPortalTabs: PropTypes.func.isRequired,
getDescendantPortalTabs: PropTypes.func.isRequired
};
Expand Up @@ -40,10 +40,10 @@ export const global = {
vertical = undefined
}) => {
return {
padding: ` ${all||vertical||top}px
${all||horizontal||right}px
${all||vertical||bottom}px
${all||horizontal||left}px`
padding: ` ${all || vertical || top}px
${all || horizontal || right}px
${all || vertical || bottom}px
${all || horizontal || left}px`
};
},

Expand All @@ -58,10 +58,10 @@ export const global = {
}) => {
return {
margin: `
${all||vertical||top}px
${all||horizontal||right}px
${all||vertical||bottom}px
${all||horizontal||left}px`
${all || vertical || top}px
${all || horizontal || right}px
${all || vertical || bottom}px
${all || horizontal || left}px`
};
},

Expand All @@ -83,7 +83,7 @@ export const global = {
};
},

merge: (...objs) => Object.assign({}, ...objs)
merge: (...objects) => Object.assign({}, ...objects)
}

};
Expand Up @@ -11,5 +11,4 @@ export const IconSelector = (type) => {
default:
return ArrowIcon;
}

};

0 comments on commit 2a382be

Please sign in to comment.