From caea1810518cf1333928a2e990bb33b42575d34f Mon Sep 17 00:00:00 2001 From: jokade Date: Sat, 7 Feb 2015 13:48:24 +0100 Subject: [PATCH] Remodel Directive API * Closes #29 --- build.sbt | 9 +++++---- project/plugins.sbt | 4 +++- src/main/scala/biz/enef/angular/Directive.scala | 9 +++++---- tests/src/test/scala/test/DirectiveTest.scala | 17 ++++++++++------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/build.sbt b/build.sbt index 14e1a5e..d5005ef 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -//import SonatypeKeys._ +import SonatypeKeys._ lazy val commonSettings = Seq( organization := "biz.enef", @@ -14,7 +14,7 @@ lazy val root = project.in(file(".")). enablePlugins(ScalaJSPlugin). settings(commonSettings: _*). settings(publishingSettings: _*). - //settings(sonatypeSettings: _*). + settings(sonatypeSettings: _*). settings( name := "scalajs-angulate", libraryDependencies ++= Seq( @@ -29,12 +29,13 @@ lazy val tests = project. dependsOn(root). enablePlugins(ScalaJSPlugin). settings(commonSettings: _*). + settings(utest.jsrunner.Plugin.utestJsSettings: _*). settings( publish := {}, scalacOptions ++= angulateDebugFlags, scalaJSStage := FastOptStage, - libraryDependencies += "com.lihaoyi" %% "utest" % "0.3.0", - testFrameworks += new TestFramework("utest.runner.Framework"), + //libraryDependencies += "com.lihaoyi" %% "utest" % "0.3.0", + //testFrameworks += new TestFramework("utest.runner.Framework"), jsDependencies += RuntimeDOM, jsDependencies += "org.webjars" % "angularjs" % "1.3.8" / "angular.min.js" % "test", jsDependencies += "org.webjars" % "angularjs" % "1.3.8" / "angular-mocks.js" % "test" diff --git a/project/plugins.sbt b/project/plugins.sbt index c07b9d8..a73ee98 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,4 @@ -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.0") +//addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.0-RC2") +addSbtPlugin("com.lihaoyi" % "utest-js-plugin" % "0.2.5-RC1") diff --git a/src/main/scala/biz/enef/angular/Directive.scala b/src/main/scala/biz/enef/angular/Directive.scala index 0eef30a..da75b8e 100644 --- a/src/main/scala/biz/enef/angular/Directive.scala +++ b/src/main/scala/biz/enef/angular/Directive.scala @@ -19,10 +19,11 @@ trait Directive { def priority: Int = ??? - def controller(ctrl: ControllerType, scope: Scope, elem: JQLite, attrs: Attributes) : Unit = ??? + def controller(ctrl: ControllerType, scope: ScopeType, elem: JQLite, attrs: Attributes) : Unit = ??? //def controller(scope: js.Dynamic, elem: JQLite, attrs: Attributes) : Unit = ??? - type ControllerType <: js.Object + type ControllerType <: js.Any + type ScopeType <: js.Any def controllerAs: String = ??? @@ -35,8 +36,8 @@ trait Directive { def scope: Boolean = ??? def isolateScope: js.Dictionary[String] = ??? - def postLink(scope: Scope, element: JQLite, attrs: Attributes) : Unit = ??? - def postLink(scope: Scope, element: JQLite, attrs: Attributes, controller: ControllerType) : Unit = ??? + def postLink(scope: ScopeType, element: JQLite, attrs: Attributes) : Unit = ??? + def postLink(scope: ScopeType, element: JQLite, attrs: Attributes, controller: ControllerType) : Unit = ??? //def preLink(scope: Scope, element: JQLite, attrs: Attributes, controller: js.Dynamic) : Unit = ??? def compile(tElement: js.Dynamic, tAttrs: Attributes) : js.Any = ??? diff --git a/tests/src/test/scala/test/DirectiveTest.scala b/tests/src/test/scala/test/DirectiveTest.scala index 140be5c..05d0558 100644 --- a/tests/src/test/scala/test/DirectiveTest.scala +++ b/tests/src/test/scala/test/DirectiveTest.scala @@ -43,9 +43,9 @@ object DirectiveTest extends AngulateTestSuite { val $compile = injection[js.Dynamic]("$compile") val $rootScope = injection[Scope]("$rootScope") - val elem = $compile("""""").apply(literal()).asInstanceOf[JQLite] + val elem = $compile("""""").apply(literal()).asInstanceOf[JQLite] //$rootScope.$digest() - println( elem.head.textContent ) + //println( elem.head.textContent ) } } @@ -77,15 +77,18 @@ object DirectiveTest extends AngulateTestSuite { class Directive3 extends Directive { override type ControllerType = Directive3Ctrl - override def controllerAs = "ctrl" - override val template = "ctrl.bar" - - //override def isolateScope = js.Dictionary() + //override val controllerAs = "ctr" + override val template = "
x
" + override def isolateScope = js.Dictionary( + "x" -> "=x" + ) +/* override def controller(ctrl: ControllerType, scope: Scope, elem: JQLite, attrs: Attributes): Unit = { println(ctrl) ctrl.bar = "foo" ctrl.click = () => ctrl.bar = "bar" - } + + }*/ } }