Improves style further.

This commit is contained in:
Josh Callebaut 2015-12-21 15:42:46 -08:00
parent 9ba9d8ab4d
commit 314f8256ee
3 changed files with 37 additions and 65 deletions
app
styles/editor
templates/editor
views/editor

View file

@ -1,22 +1,12 @@
#thang-tasks-view
#taskTable
#thangTable
width: 100%
.taskOwner
width: 12.5%
.tasksTable
width: 87.5%
.taskDescription:nth-of-type(odd)
background-color: rgba(0, 0, 0, 0.0625)
.taskDescription
width: 100%
padding-left: 4px
border-radius: 4px
&:hover
background-color: rgba(0, 0, 0, 0.125)
.task
width: 100%
.tasks
width: 87.5%
.taskOwner
width: 12.5%

View file

@ -7,44 +7,23 @@ block content
input#descSearch(placeholder='Filter: Task Description')
hr
if view.processedThangs
table.table#taskTable
table.table.table-striped#thangTable
tr
th Thang Name
th Task List
for thang in view.processedThangs
if (thang.tasks && thang.tasks.filter(function(_elem) {return !_elem.complete}).length > 0) || false
tr
td.taskOwner
a(href= 'thang/' + thang.get('slug'))
| #{thang.get('name')}
td.tasksTable
for task in (thang.tasks || [])
if !task.complete
div.taskDescription
| #{task.name}
if view.hasIncompleteTasks(thang)
+thangRow(thang)
else
span No view.processedThangs
//
block content
#thang-tasks-view
if view.processedThangs
input#search
hr
table.table#taskTable
tr
th Thang Name
th Task List
for thang in view.processedThangs.models
if (thang.get('tasks') && thang.get('tasks').filter(function(_elem) {return !_elem.complete}).length > 0) || false
tr
td.taskOwner
a(href= 'thang/' + thang.get('slug'))
| #{thang.get('name')}
td.tasksTable
for task in (thang.get('tasks') || [])
if !task.complete
div.taskDescription
| #{task.name}
else
span Loading...
mixin thangRow(thang)
tr
td.taskOwner
a(href= 'thang/' + thang.get('slug'))= thang.get('name')
td.tasks
table.table-striped.table-hover.tasksTable
for task in (thang.tasks || [])
if !task.complete
tr
td= task.name

View file

@ -18,28 +18,31 @@ module.exports = class ThangTasksView extends RootView
comparator: @sortThangs
)
@lastLoad = (new Date()).getTime()
@listenTo(@thangs, 'sync', @onColLoaded)
@listenTo(@thangs, 'sync', @onThangsLoaded)
@supermodel.loadCollection(@thangs, 'thangs')
searchUpdate: ->
if !@lastLoad? or (new Date()).getTime() - @lastLoad > 60 * 1000 * 1 # Update only after a minute from last update.
if not @lastLoad? or (new Date()).getTime() - @lastLoad > 60 * 1000 * 1 # Update only after a minute from last update.
@thangs.fetch()
@listenTo(@thangs, 'sync', @onColLoaded)
@listenTo(@thangs, 'sync', @onThangsLoaded)
@supermodel.loadCollection(@thangs, 'thangs')
@lastLoad = (new Date()).getTime()
else
@onColLoaded()
onColLoaded: ->
@processedThangs = @thangs.filter((_elem) ->
return _elem.get('name').toLowerCase().indexOf($('#nameSearch')[0].value.toLowerCase()) isnt -1
)
@onThangsLoaded()
onThangsLoaded: ->
@processedThangs = @thangs.filter (_elem) ->
# Case-insensitive search of input vs name.
return ///#{$('#nameSearch')[0].value}///i.test _elem.get('name')
for thang in @processedThangs
thang.tasks = _.filter(thang.attributes.tasks, (_elem) ->
return _elem.name.toLowerCase().indexOf($('#descSearch')[0].value.toLowerCase()) isnt -1
)
newContent = $(template({me:me, view:@}))
@$el.find('#taskTable').replaceWith($(newContent[1]).find('#taskTable'))
thang.tasks = _.filter thang.attributes.tasks, (_elem) ->
# Similar case-insensitive search of input vs description (name).
return ///#{$('#descSearch')[0].value}///i.test _elem.name
@renderSelectors '#thangTable'
sortThangs: (a, b) ->
a.get('name').localeCompare(b.get('name'))
a.get('name').localeCompare(b.get('name'))
# Jade helper
hasIncompleteTasks: (thang) ->
return thang.tasks and thang.tasks.filter((_elem) -> return not _elem.complete).length > 0