From b9a61acfd0d14156ebf89cfb9a54c87371b9785b Mon Sep 17 00:00:00 2001 From: SylTi Date: Sun, 30 Nov 2014 05:19:05 +0100 Subject: [PATCH] [enhancement] directive working #58 --- client/app/admin/admin.controller.js | 5 ++ client/app/admin/admin.jade | 3 +- .../adminProjectList.directive.js | 55 ++++++++++++------- .../adminProjectList/adminProjectList.jade | 43 +++++++-------- 4 files changed, 62 insertions(+), 44 deletions(-) diff --git a/client/app/admin/admin.controller.js b/client/app/admin/admin.controller.js index 2e2dbfa..87e465d 100644 --- a/client/app/admin/admin.controller.js +++ b/client/app/admin/admin.controller.js @@ -99,6 +99,11 @@ angular.module('bitCrowdFundsApp') $scope.message = 'Something wrong happend'; }); }; + //console.log($scope.projects); + /*$scope.$watch('projects', function(newVal, oldVal) { + + console.log($scope.projects); + }, true);*/ /*$scope.$watch('projects', function(projs) { diff --git a/client/app/admin/admin.jade b/client/app/admin/admin.jade index ce71bde..d1501b8 100644 --- a/client/app/admin/admin.jade +++ b/client/app/admin/admin.jade @@ -67,7 +67,8 @@ div(ng-include='"components/navbar/navbar.html"') ul.list-group.well tabset(justified='true', type="'pills'") tab(heading='All').tabText.label-primary - span(adminProjectList projects="projects") + li.list-group-item(ng-repeat='project in projects') + admin-project-list //- li.list-group-item(ng-repeat='project in projects') //- strong //- span.label.label-success(ng-show="project.amountRaised >= project.amountToRaise") Finished diff --git a/client/components/adminProjectList/adminProjectList.directive.js b/client/components/adminProjectList/adminProjectList.directive.js index 2edbfec..2f7c03a 100644 --- a/client/components/adminProjectList/adminProjectList.directive.js +++ b/client/components/adminProjectList/adminProjectList.directive.js @@ -1,32 +1,45 @@ 'use strict'; angular.module('bitCrowdFundsApp') - .directive('adminProjectList', function () { + .directive('adminProjectList', function ($timeout) { return { - //templateUrl: 'components/adminProjectList/adminProjectList.html', + templateUrl: 'components/adminProjectList/adminProjectList.html', restrict: 'EA', - //replace: true, - //transclude: true, - //scope: true - scope: { - projects: '=' - }, - //replace: true, - //transclude: true, - /*controller: function($scope) + //template: '
this is my template
', + /*scope: { + project: '=' + },*/ + link: function (scope,el, attrs) { - $scope.$watch('projects', function(v) { - $scope.projects = v; + /*scope.$watch('project', function (newMyData) { + //Build the table and insert it into DOM }); - }*/ - link: function(scope, element, attrs) - { - element.text('
shit
'); - scope.$on("Data_Ready", function () + console.log("before: " + el.html()); + + $timeout(function() { - element.text('
shit
'); - }); - } + console.log("After: " + el.html()); + $timeout(function() + { + console.log("After2: " + el.html()); + }, 0); + }, 0); + $timeout(function () + { + console.log('HERE'); + });*/ + }, + /*template: + [ + //'
  • ', + '', + ' Finished', + ' clas="label label-warning" ng-show="project.amountRaised !== 0 && project.amountRaised < project.amountToRaise"> Ongoing', + ' class="label label-default" ng-show="project.amountRaised === 0"> Not started', + '  ', + ' {{project.name}} ({{project.amountRaised | toBTC}} / {{project.amountToRaise | toBTC}}' + ].join('')*/ + //template: 'test' }; }); diff --git a/client/components/adminProjectList/adminProjectList.jade b/client/components/adminProjectList/adminProjectList.jade index 7f0970f..93fa8d6 100644 --- a/client/components/adminProjectList/adminProjectList.jade +++ b/client/components/adminProjectList/adminProjectList.jade @@ -1,22 +1,21 @@ -li.list-group-item(ng-repeat='project in projects') - strong - span.label.label-success(ng-show="project.amountRaised >= project.amountToRaise") Finished - span.label.label-warning(ng-show="project.amountRaised !== 0 && project.amountRaised < project.amountToRaise") Ongoing - span.label.label-default(ng-show="project.amountRaised === 0") Not started - |    - span {{project.name}} ({{project.amountRaised | toBTC}} / {{project.amountToRaise | toBTC}}) - br - small.text-muted - span Project created - |   - b(am-time-ago="project.dateCreat") - |   - span and finishing - |   - b(am-time-ago="project.dateEndCampaign") - .pull-right - a(ng-href='/projects/{{project.slug}}/edit') - span.glyphicon.glyphicon-pencil - |      - a.trash(ng-click='deleteProject(project)') - span.glyphicon.glyphicon-trash +strong + span.label.label-success(ng-show="project.amountRaised >= project.amountToRaise") Finished + span.label.label-warning(ng-show="project.amountRaised !== 0 && project.amountRaised < project.amountToRaise") Ongoing + span.label.label-default(ng-show="project.amountRaised === 0") Not started + |    + span {{project.name}} ({{project.amountRaised | toBTC}} / {{project.amountToRaise | toBTC}}) +br +small.text-muted + span Project created + |   + b(am-time-ago="project.dateCreat") + |   + span and finishing + |   + b(am-time-ago="project.dateEndCampaign") +.pull-right + a(ng-href='/projects/{{project.slug}}/edit') + span.glyphicon.glyphicon-pencil + |      + a.trash(ng-click='deleteProject(project)') + span.glyphicon.glyphicon-trash