Skip to content

Commit

Permalink
Added mock behaviour for archiving cards in the view layer
Browse files Browse the repository at this point in the history
  • Loading branch information
gardeman committed Dec 11, 2009
1 parent 365ef5c commit a87c5fb
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,3 +9,4 @@ grails-app/conf/SecurityConfig.groovy
*.ipr
*.iws
.idea

7 changes: 4 additions & 3 deletions grails-app/conf/BootStrap.groovy
Expand Up @@ -118,9 +118,10 @@ class BootStrap {
if( Board.list().size() == 0 ){
Board board = new Board().save()

eventService.persist(new PhaseEventCreate(title: "Backlog", phasePos: 0, user: adminUser, board: board))
eventService.persist(new PhaseEventCreate(title: "WIP", phasePos: 1, cardLimit: 5, user: adminUser, board: board))
eventService.persist(new PhaseEventCreate(title: "Done", phasePos: 2, user: adminUser, board: board))
eventService.persist(new PhaseEventCreate(title: "Backlog", position: 0, user: adminUser, board: board))
eventService.persist(new PhaseEventCreate(title: "WIP", position: 1, cardLimit: 5, user: adminUser, board: board))
eventService.persist(new PhaseEventCreate(title: "Done", position: 2, user: adminUser, board: board))
eventService.persist(new PhaseEventCreate(title: "Archive", position: 3, user: adminUser, board: board))
}
}

Expand Down
2 changes: 1 addition & 1 deletion grails-app/domain/se/qbranch/qanban/Board.groovy
Expand Up @@ -22,6 +22,6 @@ class Board {
}

static hasMany = [phases:Phase]

List phases = []

}
1 change: 0 additions & 1 deletion grails-app/domain/se/qbranch/qanban/Phase.groovy
Expand Up @@ -27,7 +27,6 @@ class Phase {
domainId( nullable: false, unique: true, blank: false)
}

//TODO: Titta mer på det här!
static hasMany = [cards:Card]

String title
Expand Down
29 changes: 29 additions & 0 deletions grails-app/taglib/QanbanTagLib.groovy
Expand Up @@ -22,6 +22,35 @@ class QanbanTagLib {

static namespace = 'qb'

def renderPhases = { attrs ->
if( !attrs.template )
return out << "You need to specify a template"
if( !attrs.phases )
return out << "You need to specify a collection of phases"
if( attrs.showArchive && attrs.showArchive != "true" && attrs.showArchive != "false" )
return out << "The attribute 'showArchive' can only be true/false"


def output = ""
def elementNumber = 0

attrs.phases.each{
elementNumber += 1
if( elementNumber < attrs.phases.size() || attrs.showArchive == "true" ) {
output += render(template:attrs.template,model:[phase:it])
}
}
out << output
}

def enableArchiveButton = { attrs->
if( isSecondLastPhase(attrs.phase) ) out << '<div id="archiveBtn"> </div>'
}

private boolean isSecondLastPhase(phase){
phase.board.phases.indexOf(phase) == phase.board.phases.size()-2
}

def maxCardCount = { attrs ->
def maxNumberOfCards = 0
attrs.phases?.each{
Expand Down
10 changes: 5 additions & 5 deletions grails-app/views/board/_board.gsp
Expand Up @@ -6,7 +6,9 @@
.phaseAutoHeight{ height: <qb:maxCardCount phases="${it.phases}" cardHeight="7" unit="em"/>; } /*7 em*/
</style>
</g:if>
<g:ifAllGranted role="ROLE_QANBANADMIN">


<g:ifAllGranted role="ROLE_QANBANADMIN">
<div id="adminmenu">
<ul>
<li><a href="${createLink(controller:'card',action:'create')}" class="addCardLink"><g:message code="layout.inside.menu.addCard"/></a></li>
Expand All @@ -20,10 +22,8 @@


<ul id="phaseList">

<g:each var="phase" in="${it.phases}">
<g:render template="/phase/phase" model="['phase':phase]"/>
</g:each>

<qb:renderPhases phases="${it.phases}" showArchive="false" template="/phase/phase"/>

</ul>

Expand Down
10 changes: 10 additions & 0 deletions grails-app/views/javascript/_board.gsp
Expand Up @@ -99,6 +99,16 @@

});

/* $('#archiveBtn').click(function(event){

if( $(this).css('background-position') == '3px -94px' ){
$(this).css('background-position','-13px -94px');
}else{
$(this).css('background-position','3px -94px');
}
event.preventDefault();
});
*/
}

/* TODO: Change beforeInjection to getNewElementCallback to break out some missplaced logic */
Expand Down
27 changes: 25 additions & 2 deletions grails-app/views/javascript/_phase.gsp
Expand Up @@ -180,6 +180,7 @@ function phaseFormRefresh(formData,dialogSelector,successTitle,successMessage){
}

}).parent().animate({opacity:0.3},300);
ui.item.animate({opacity:0.6},300);

var initPos = ui.item.prevAll().length + 1;
var elementId = ui.item.attr('id');
Expand All @@ -191,16 +192,22 @@ function phaseFormRefresh(formData,dialogSelector,successTitle,successMessage){
});

if ( $nextPhase.is('.phase') ){
$currentPhase.sortable('option','connectWith','#'+$nextPhase.attr('id')+'.available')

$currentPhase.sortable('option','connectWith','#'+$nextPhase.attr('id')+'.available');

}else if ( $currentPhase.parent().find('#archiveBtn').size() == 1 ){

$currentPhase.sortable('option','connectWith','#archiveBtn');
}

});
}

function enableSortableOnPhase($phase){
$phase.sortable({
placeholder: 'placeholder',
stop: function(event,ui){

ui.item.animate({opacity:1},300);
recalculateHeightAndUpdateCardCount();
$('.phase').parent().animate({opacity: 1},300);

Expand Down Expand Up @@ -280,6 +287,22 @@ function phaseFormRefresh(formData,dialogSelector,successTitle,successMessage){

}
});

var $archiveBtn = $phase.parent().find('#archiveBtn');
if( $archiveBtn.size() == 1 ){
var acceptSelector = '#' + $phase.attr('id') + ' > .card';
$archiveBtn.droppable({
hoverClass: 'cardHover',
accept: acceptSelector,
tolerance: 'pointer',
drop: function(event,ui){
// $.qPost(${createLink(controller:'card',action:'archive')})
ui.draggable.remove();
}

});
}

}


1 change: 1 addition & 0 deletions grails-app/views/mainView/view.gsp
Expand Up @@ -10,6 +10,7 @@
<g:javascript src="jquery/jquery.ui.core.js"/>
<g:javascript src="jquery/jquery.ui.sortable.js"/>
<g:javascript src="jquery/jquery.ui.draggable.js"/>
<g:javascript src="jquery/jquery.ui.droppable.js"/>
<g:javascript src="jquery/jquery.ui.dialog.js"/>
<g:render template="/javascript/qanbanOnLoad"/>
<g:render template="/javascript/qanbanFunctions"/>
Expand Down
10 changes: 8 additions & 2 deletions grails-app/views/phase/_phase.gsp
Expand Up @@ -7,15 +7,21 @@

<g:ifAllGranted role="ROLE_QANBANADMIN">
<a href="#edit" class="editPhaseLink" id="phaseLink_${phase.id}"> </a>

</g:ifAllGranted>

<qb:enableArchiveButton phase ="${phase}"/>

<h3><g:fieldValue bean="${phase}" field="title" /></h3>

<div class="limitLine">
<div class="limitLine">
<g:if test="${phase.cardLimit}">${phase.cards.size()}/${phase.cardLimit}</g:if>
<g:else><g:message code="_phase.noLimit"/></g:else>
</div>

</div>
</div>


<ul class="phase phaseAutoHeight
<g:if test="${phase.cardLimit && phase.cards.size() > 0 && (phase.cardLimit/phase.cards.size()) != 1 || phase.cardLimit != phase.cards.size()}">
available
Expand Down
2 changes: 1 addition & 1 deletion test/unit/se/qbranch/qanban/BoardTests.groovy
Expand Up @@ -29,7 +29,7 @@ class BoardTests extends GrailsUnitTestCase {

void testHasPhases() {
mockDomain(Board)
def b = new Board().save()
def b = new Board(domainId: 'domainId').save()
assertEquals 0, b.phases.size()
}
}
32 changes: 28 additions & 4 deletions web-app/css/style.css
Expand Up @@ -33,7 +33,7 @@
padding: 0 18px;
line-height: 30px;
display: inline-block;
outline: none;

}

#mainmenu a:hover{
Expand Down Expand Up @@ -91,6 +91,7 @@ a {
font-size: 1.2em;
color: #333;
text-decoration: none;
outline: none;
}

a:hover {
Expand Down Expand Up @@ -235,6 +236,30 @@ h4{}
background-image: url(custom-theme/images/ui-icons_fd0000_256x240.png);
}

#archiveBtn {
display: block;
position: absolute;
top: -2px;
right: 23px;
width: 19px;
height: 19px;
padding: 1px;
background-image: url(custom-theme/images/ui-icons_222222_256x240.png);
background-repeat: no-repeat;
background-position: 3px -94px;
}

#archiveBtn:hover {
background-image: url(custom-theme/images/ui-icons_fd0000_256x240.png);
}

#archiveBtn.cardHover {
background-image: url(custom-theme/images/ui-icons_fd0000_256x240.png);
background-position: -13px -94px;
}



ul.phase {
list-style: none;
min-height: 30px;
Expand Down Expand Up @@ -265,9 +290,7 @@ ul.phase {
border: 1px solid #2E83FF !important;
}

.myCard {

}
.cardTop {
border-bottom: solid;
border-width: 1px;
Expand Down Expand Up @@ -362,12 +385,13 @@ ul.phase {
*/
.phaseHeader .limitLine {
height: 1em;
background-color: #bbb;
background-image: url(../images/head_fade.png);
text-align: center;
line-height: 1em;
position: absolute;
width: 100%;
bottom: 0;
color: #fff;
}

/*******/
Expand Down

0 comments on commit a87c5fb

Please sign in to comment.