Skip to content

Commit

Permalink
#107 closed: 'Add delete button for categories'
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatov committed Aug 5, 2011
1 parent ece6406 commit 14e5d6a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 58 deletions.
70 changes: 29 additions & 41 deletions src/main/scala/scala/tools/colladoc/model/mapper/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ object User extends User with KeyedMetaMapper[Long, User] {
S.notice("Category " + name + " already exists.")
Noop
case _ =>
Category.create.name(name).save
Category.create.name(name).save()
S.notice("Category " + name + " successfully created.")
Replace("categories_table", categoriesList) & Jq(Str(".button")) ~> Button()
Replace("categories_form", categoriesSettings) & Jq(Str(".button")) ~> Button()
}
}

Expand All @@ -316,7 +316,7 @@ object User extends User with KeyedMetaMapper[Long, User] {
c.name.is,
text => {
if (c.name.is != text )
c.name(text).save
c.name(text).save()
Noop
}
)
Expand All @@ -326,71 +326,59 @@ object User extends User with KeyedMetaMapper[Long, User] {
{
SHtml.ajaxCheckbox(
c.anonymousView,
bool => { c.anonymousView(bool).save; Noop }
bool => { c.anonymousView(bool).save(); Noop }
)
}
</td>
<td>
{
SHtml.ajaxCheckbox(
c.anonymousPost,
bool => { c.anonymousPost(bool).save; Noop }
bool => { c.anonymousPost(bool).save(); Noop }
)
}
</td>
<td>
{
SHtml.a(
ColladocConfirm("Confirm delete"),
() => { c.valid(false).save; Replace("categories_table", categoriesList) & Jq(Str(".button")) ~> Button() },
Text("Delete"),
() => { c.valid(false).save(); Replace("categories_form", categoriesSettings) & Jq(Str(".button")) ~> Button() },
SHtml.span(NodeSeq.Empty, Noop, ("class", "ui-icon ui-icon-trash")),
("class", "button")
)
}
</td>
</tr>

def categoriesList: NodeSeq =
<div id="categories_table">
<h3>Categories</h3>
<table>
<tr>
<th>Name</th>
<th>Anonymous viewable</th>
<th>Anonymous postable</th>
<th></th>
</tr>
{ Category.all map categoryToHtml _ }
</table>
</div>

val form =
<xml:group>
{ categoriesList }
<div id="categories_form">
<lift:form class="category">
<fieldset>
<p>
<table id="category_add_line">
<tr>
<td>
<category:name class="text required ui-widget-content ui-corner-all" />
</td>
<td>
<category:save />
</td>
</tr>
</table>
</p>
<category:submit />
</fieldset>
<h3>Categories</h3>
<table id="categories_table">
<tr>
<th>Name</th>
<th>Anonymous viewable</th>
<th>Anonymous postable</th>
<th></th>
</tr>
{ Category.all map categoryToHtml _ }
<tr>
<td colspan="3">
<category:name class="text required ui-widget-content ui-corner-all" />
</td>
<td>
<category:save />
</td>
</tr>
</table>
<category:submit />
</lift:form>
</xml:group>

</div>

bind("category", form,
"name" -%> SHtml.text(name, name = _),
"submit" -> SHtml.hidden(doSave _),
"save" -> SHtml.a(Text("Add"), SubmitFormWithValidation(".category"), ("class", "button"))
"save" -> SHtml.a(SHtml.span(NodeSeq.Empty, Noop, ("class", "ui-icon ui-icon-plus")), SubmitFormWithValidation(".category"), ("class", "button"))
)
}

Expand Down
22 changes: 5 additions & 17 deletions src/main/webapp/cosettings.css
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,17 @@
padding-top: 0.2em;
}

#categories_table {
width: 600px;
}

#categories_table td {
border-bottom: 1px solid #E5E5E5;
padding: 10px;
}

#categories_table th {
border-bottom: 1px solid #E5E5E5;
font-weight: bold;
padding: 10px;
}
Expand All @@ -189,23 +194,6 @@
margin: 50px;
}

#category_add_line {
width: 652px;
}

#category_add_line td {
padding: 10px;
}

#category_add_line th {
font-weight: bold;
padding: 10px;
}

#category_add_line tr {
margin: 50px;
}

.test {margin: 5px;}

#discussions_settings h3 {
Expand Down
2 changes: 2 additions & 0 deletions src/main/webapp/scripts/cosettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ $(document).ready(function() {
});

$(".create").validate();

$("#categories_table > tbody > tr:last > td").css({'border': 'none'});
});

0 comments on commit 14e5d6a

Please sign in to comment.