care about URL presentation
authorSteve Hackbarth <stephenhackbarth@gmail.com>
Thu, 14 Aug 2014 15:23:39 +0000 (11:23 -0400)
committerSteve Hackbarth <stephenhackbarth@gmail.com>
Thu, 14 Aug 2014 15:23:39 +0000 (11:23 -0400)
lib/backbone-x/source/router.js
lib/enyo-x/source/views/workspace.js

index a22723d..520175c 100644 (file)
@@ -1,7 +1,7 @@
 /*jshint indent:2, curly:true, eqeqeq:true, immed:true, latedef:true,
 newcap:true, noarg:true, regexp:true, undef:true, trailing:true,
 white:true*/
-/*global XT:true, XM:true, Backbone:true, console:true */
+/*global XT:true, XM:true, XV:true, Backbone:true, console:true */
 
 (function () {
 
@@ -11,9 +11,14 @@ white:true*/
       "workspace/:recordType/:id": "workspace"
     },
 
-    workspace: function (recordType, id) {
+    /**
+      @objectName {String} in format sales-order
+     */
+    workspace: function (objectName, id) {
+      var recordType = "XM." + objectName.charAt(0).toUpperCase() +
+        objectName.slice(1).camelize();
       var inEvent = {
-        workspace: "XV." + recordType + "Workspace",
+        workspace: XV.getWorkspace(recordType),
         id: id
       };
       XT.app.waterfallWorkspace(null, inEvent);
index d7e2287..8fdaa6c 100644 (file)
@@ -515,8 +515,8 @@ trailing:true, white:true, strict: false*/
         attrs[Klass.prototype.idAttribute] = recordId;
         this.setValue(Klass.findOrCreate(attrs));
         XM.backboneRouter.navigate("workspace/" +
-          this.kind.substring(3).replace("Workspace", "") + "/" +
-          recordId);
+          this.value.recordType.substring(3).decamelize().replace(/_/g, "-") +
+          "/" + recordId);
       }
       _setBindings(this, "on");
       this.fetch();