Created
May 2, 2016 20:27
-
-
Save beckettkev/4701482e0138e3762a7232166ddc86fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Issues | |
- We need to swap in value to the layout (react select etc..) | |
- Passing in new layouts from options is back on the cards :) | |
*/ | |
//Examples of use... | |
BLAH_BLAH_BLAH: [ | |
... | |
{ | |
key: 0, | |
label: 'Name (with profile link)', | |
template: function(key, person) { | |
return ( | |
{value(key, person.preferredName)} | |
); | |
} | |
}, | |
... | |
{ | |
key: 9, | |
label: 'Documents', | |
template: function(key, person) { | |
const callback = search.bind(this, person.items.Cells.PreferredName, 'IsDocument:1 Author:'); | |
return ( | |
{button(key, 'insert_drive_file', callback)} | |
); | |
} | |
}, | |
... | |
]; | |
/* | |
Working with object inheritance... | |
item.value | |
item.link | |
item.persona | |
item.icon | |
item.button | |
*/ | |
const item = () => { | |
const value = (key, value) => { | |
return ( | |
<span key={'item-text-' + key}> | |
{value} | |
</span> | |
); | |
} | |
const link = (href, target, key, value) => { | |
return ( | |
<span key={key}> | |
<a href={href} target={target}> | |
{value} | |
</a> | |
</span> | |
); | |
} | |
const persona = (person, key) => { | |
return ( | |
<div key={key}> | |
<Persona | |
member={name: person.items.Cells.PreferredName, | |
loginName: 'i:0#.f|membership|' + person.items.Cells.WorkEmail, | |
email: person.items.Cells.WorkEmail} /> | |
</div> | |
); | |
} | |
const icon = (icon) => { | |
return ( | |
<i className={'material-icons'} styleName={icon}>{icon}</i> | |
); | |
} | |
const button = (key, icon, callback) => { | |
return ( | |
<span key={'command-' + key} styleName='command' className='commandor'> | |
<Button | |
icon={icon} | |
floating accent mini | |
onClick={callback} /> | |
</span> | |
); | |
} | |
const search = (name, mp) => { | |
window.location.href = window.location.protocol + '//' + window.location.host + '/search/Pages/results.aspx?k=' + mp + name; | |
} | |
}; | |
//...meanwhile... | |
card (person, layout, index) { | |
let child = Object.create(item); | |
let combined = []; | |
layout.forEach(function (element) { | |
//the template function for our item is brought from the layout item | |
child.template = element.template; | |
combined.push(child.template(index, person)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment