Skip to content

Commit 329a213

Browse files
committed
lookup dynamic list
1 parent 93b6122 commit 329a213

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
Copyright (c) 2015, salesforce.com, inc. All rights reserved.
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
6+
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
7+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8+
*/
9+
10+
'use strict';
11+
12+
import React from 'react';
13+
import SLDSLookup from '../../../components/SLDSLookup';
14+
15+
import {default as PrismCode} from 'react-prism/lib/PrismCode';
16+
17+
18+
const items = [
19+
{label:'Paddy\'s Pub'},
20+
{label:'Tyrell Corp'},
21+
{label:'Paper St. Soap Company'},
22+
{label:'Nakatomi Investments'},
23+
{label:'Acme Landscaping'},
24+
{label:'Acme Construction'}
25+
];
26+
27+
28+
29+
module.exports = React.createClass( {
30+
31+
getDefaultProps () {
32+
return {};
33+
},
34+
35+
getInitialState () {
36+
return {
37+
items:[
38+
{label:'Acme Construction'}
39+
]
40+
};
41+
},
42+
43+
componentDidMount(){
44+
let times = 0;
45+
setInterval(()=>{
46+
let items = this.state.items;
47+
items.push({label:'SUPER ITEM '+(times++)});
48+
this.setState({items:items});
49+
},1000);
50+
},
51+
52+
newItem(){
53+
alert('New Item Clicked');
54+
},
55+
56+
searchRecords(){
57+
alert('Search Records Clicked');
58+
},
59+
60+
render() {
61+
return (
62+
63+
<div className="slds-p-around--medium">
64+
Dynamic list
65+
<div className="slds-p-vertical--large">
66+
<SLDSLookup
67+
items={this.state.items}
68+
label="Accounts"
69+
type="account"
70+
onNewItem={this.newItem}
71+
onSearchRecords={this.searchRecords}
72+
/>
73+
</div>
74+
75+
</div>
76+
77+
78+
);
79+
}
80+
});

demo/pages/HomePage/index.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import {ButtonIcon, Icon} from "./../../../components/SLDSIcons";
1717
import ButtonSection from './ButtonSection';
1818
import ButtonGroupSection from './ButtonGroupSection';
1919
import LookupBaseSection from './LookupBaseSection';
20+
21+
import LookupBaseDynamicSection from './LookupBaseDynamicSection';
22+
23+
2024
import PicklistBaseSection from './PicklistBaseSection';
2125
import PicklistBaseCustomSection from './PicklistBaseCustomSection';
2226

@@ -71,6 +75,8 @@ module.exports = React.createClass( {
7175

7276
<LookupBaseSection />
7377

78+
<LookupBaseDynamicSection />
79+
7480
<PicklistBaseSection />
7581

7682
<ModalSection />

0 commit comments

Comments
 (0)