Skip to content

Commit 38537a2

Browse files
committed
Make contact page to edit contact list (can't create/delete contacts yet though),
and search page to find messages. git-svn-id: http://svn.dojotoolkit.org/src/demos/trunk@15364 560b804f-0ae3-0310-86f3-f6aa0a117693
1 parent 2995f38 commit 38537a2

File tree

3 files changed

+67
-10
lines changed

3 files changed

+67
-10
lines changed

mail/contacts.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
$email = strtolower($first) . "." . strtolower($last) . $ext[$counter%3];
1515
$display = $name . " <" . $email . ">";
1616
print "{ " .
17-
"name: '" . $name . "',\n" .
17+
"first: '" . $first . "',\n" .
18+
"last: '" . $last . "',\n" .
1819
"email: '" . $email . "',\n" .
1920
"display: '" . $display . "'\n" .
2021
"},\n";

mail/demo.html

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,26 @@
147147
</script>
148148
</div>
149149
</div>
150-
<div dojoType="dijit.layout.AccordionPane" title="Address Book">
151-
<table dojoType="dojox.grid.DataGrid" store="mailStore"
152-
query="{ type: 'address' }"
153-
id="addresses" style="width: 100%; height: 100%;">
154-
<thead>
150+
<div dojoType="dijit.layout.AccordionPane" title="Search Messages">
151+
<form dojoType="dijit.form.Form" jsId="searchForm">
152+
<table>
155153
<tr>
156-
<th field="label" width="200px">User Name</th>
154+
<td><label for="subjectSearch">Subject:</label></td>
155+
<td><input dojoType="dijit.form.TextBox" id="subjectSearch" name="label"></td>
157156
</tr>
158-
</thead>
159-
</table>
157+
<tr>
158+
<td><label for="senderSearch">Sender:</label></td>
159+
<td><input dojoType="dijit.form.TextBox" id="senderSearch" name="sender"></td>
160+
</tr>
161+
<tr>
162+
<td><label for="bodySearch">Message text:</label></td>
163+
<td><input dojoType="dijit.form.TextBox" id="bodySearch" name="text"></td>
164+
</tr>
165+
<tr>
166+
<td colspan=2 align=center><button dojoType="dijit.form.Button" onClick="searchMessages">Search</button</td>
167+
</tr>
168+
</table>
169+
</form>
160170
</div>
161171
</div> <!-- end of Accordion -->
162172

@@ -201,6 +211,23 @@
201211
</div> <!-- end of "message" -->
202212

203213
</div> <!-- end of inbox -->
214+
215+
<div dojoType="dijit.layout.BorderContainer" title="Contacts">
216+
<div dojoType="dijit.layout.ContentPane" region="top">
217+
Edit your contact information from this page by clicking entries in the table below.
218+
<div id="contactIndex"></div>
219+
</div>
220+
<table dojoType="dojox.grid.DataGrid" store="contactStore" region="center" editable="true">
221+
<thead>
222+
<tr>
223+
<th field="first" width="25%" editable="true">First Name</th>
224+
<th field="last" width="25%" editable="true">Last Name</th>
225+
<th field="email" width="50%" editable="true">Email Address</th>
226+
</tr>
227+
</thead>
228+
</table>
229+
</div>
230+
204231
</div> <!-- end of TabContainer -->
205232

206233
<div dojoType="dijit.layout.ContentPane" region="bottom" id="footer" align="left">

mail/src.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ dojo.require("dijit.ProgressBar");
1818

1919
dojo.require("dijit.form.ComboBox");
2020
dojo.require("dijit.form.CheckBox");
21+
dojo.require("dijit.form.Textarea");
22+
dojo.require("dijit.form.TextBox");
23+
dojo.require("dijit.form.ComboBox");
2124
dojo.require("dijit.form.FilteringSelect");
2225
dojo.require("dijit.form.Textarea");
2326

@@ -42,7 +45,20 @@ dojo.addOnLoad(function(){
4245
dojo.style(n,"display","none");
4346
}
4447
}).play();
45-
48+
49+
// Set up handler so that when contact information is updated the "display field"
50+
// (used by "To" field drop-down") is also updated
51+
dojo.connect(contactStore, "onSet", function(/* item */ item,
52+
/* attribute-name-string */ attribute,
53+
/* object | array */ oldValue,
54+
/* object | array */ newValue){
55+
if(attribute != "display"){
56+
contactStore.setValue(item, "display",
57+
contactStore.getValue(item, "first") + " " +
58+
contactStore.getValue(item, "last") + " <" +
59+
contactStore.getValue(item, "email") + ">");
60+
}
61+
});
4662
});
4763

4864
var paneId = 1;
@@ -63,6 +79,19 @@ function onMessageClick(cell){
6379
dijit.byId("message").setContent(messageInner);
6480
}
6581

82+
function searchMessages(){
83+
// summary: do a custom search for messages across inbox folders
84+
var query = {type: "message"};
85+
var searchCriteria = searchForm.attr('value');
86+
for(var key in searchCriteria){
87+
var val = searchCriteria[key];
88+
if(val){
89+
query[key] = "*" + val + "*";
90+
}
91+
table.setQuery(query, {ignoreCase: true});
92+
}
93+
}
94+
6695
// for "new message" tab closing
6796
function testClose(pane,tab){
6897
return confirm("Are you sure you want to leave your changes?");

0 commit comments

Comments
 (0)