Permalink
Browse files

Implemented base functionality of API Not Found View.

  • Loading branch information...
1 parent 5ebfb07 commit 4a0f09d01df35def169655327f55f6db7ce0de6c @markmasse markmasse committed Nov 19, 2015
@@ -282,11 +282,6 @@ protected void service(final HttpServletRequest request, final HttpServletRespon
responseEntityFormatUri = SystemFormat.vnd_wrml_swagger_api.getFormatUri();
break;
- case WRML_METADATA_API_LOAD_PATH:
- responseModel = loadApi(requestUri);
- responseEntityMediaType = getMostAcceptableMediaType(responseModel.getSchemaUri(), acceptableMediaTypes);
- break;
-
default:
responseModel = null;
break;
@@ -342,19 +337,17 @@ else if (method == Method.Invoke) {
switch (method) {
case Get: {
- if (isNewDocumentRequest) {
+ KeysBuilder keysBuilder = new KeysBuilder(schemaLoader.getDocumentSchemaUri(), requestUri);
+ DimensionsBuilder dimensionsBuilder = new DimensionsBuilder(apiSchemaUri);
+ responseModel = context.getModel(keysBuilder.toKeys(), dimensionsBuilder.toDimensions());
+
+ if (responseModel == null && isNewDocumentRequest) {
final ApiBuilder apiBuilder = new ApiBuilder(context);
apiBuilder.uri(requestUri).title(requestUri.getHost()).docroot(UUID.randomUUID());
responseModel = apiBuilder.toApi();
final Keys apiKeys = responseModel.getKeys();
responseModel.initKeySlots(apiKeys);
}
- else {
- // Handle first time GET of a non-loaded API
- KeysBuilder keysBuilder = new KeysBuilder(schemaLoader.getDocumentSchemaUri(), requestUri);
- DimensionsBuilder dimensionsBuilder = new DimensionsBuilder(apiSchemaUri);
- responseModel = context.getModel(keysBuilder.toKeys(), dimensionsBuilder.toDimensions());
- }
break;
}
case Save: {
@@ -53,9 +53,7 @@
.apiNotFound-speech-bubble {
position: relative;
display: block;
- float: right;
max-width: 350px;
- margin-left: -30px;
padding: 10px;
p {
@@ -64,18 +62,24 @@
}
+ .wrml-model-property-input {
+ width: 400px;
+ }
+
.apiNotFound-form {
fieldset {
+
margin-left: 0px;
.control-group {
- .controls {
- margin-left: 0px;
+
+ .control-label {
+ width: 50px;
}
- }
- .apiNotFound-form-button {
- margin-left: 80px;
+ .controls {
+ margin-left: 60px;
+ }
}
}
@@ -6657,18 +6657,18 @@ input[type="color"]:focus,
#main-region .apiNotFound-speech-bubble {
position: relative;
display: block;
- float: right;
max-width: 350px;
- margin-left: -30px;
padding: 10px; }
#main-region .apiNotFound-speech-bubble p {
margin-bottom: 0px; }
+#main-region .wrml-model-property-input {
+ width: 400px; }
#main-region .apiNotFound-form fieldset {
margin-left: 0px; }
+ #main-region .apiNotFound-form fieldset .control-group .control-label {
+ width: 50px; }
#main-region .apiNotFound-form fieldset .control-group .controls {
- margin-left: 0px; }
- #main-region .apiNotFound-form fieldset .apiNotFound-form-button {
- margin-left: 80px; }
+ margin-left: 60px; }
#main-region #documentNotFound-page-header-section {
margin-bottom: 0px; }
Oops, something went wrong.
@@ -745,9 +745,7 @@ input[type="color"]:focus,
.apiNotFound-speech-bubble {
position: relative;
display: block;
- float: right;
max-width: 350px;
- margin-left: -30px;
padding: 10px;
p {
@@ -756,18 +754,24 @@ input[type="color"]:focus,
}
+ .wrml-model-property-input {
+ width: 400px;
+ }
+
.apiNotFound-form {
fieldset {
+
margin-left: 0px;
.control-group {
- .controls {
- margin-left: 0px;
+
+ .control-label {
+ width: 50px;
}
- }
- .apiNotFound-form-button {
- margin-left: 80px;
+ .controls {
+ margin-left: 60px;
+ }
}
}
@@ -490,18 +490,18 @@ input[type="color"]:focus,
#main-region .apiNotFound-speech-bubble {
position: relative;
display: block;
- float: right;
max-width: 350px;
- margin-left: -30px;
padding: 10px; }
#main-region .apiNotFound-speech-bubble p {
margin-bottom: 0px; }
+#main-region .wrml-model-property-input {
+ width: 400px; }
#main-region .apiNotFound-form fieldset {
margin-left: 0px; }
+ #main-region .apiNotFound-form fieldset .control-group .control-label {
+ width: 50px; }
#main-region .apiNotFound-form fieldset .control-group .controls {
- margin-left: 0px; }
- #main-region .apiNotFound-form fieldset .apiNotFound-form-button {
- margin-left: 80px; }
+ margin-left: 60px; }
#main-region #documentNotFound-page-header-section {
margin-bottom: 0px; }
@@ -123,6 +123,14 @@
return rewrittenUri
+
+ App.getApiUri = (documentUri) ->
+ uriAnchor = document.createElement('a')
+ uriAnchor.href = documentUri
+ uriAnchor.pathname = ""
+ apiUri = uriAnchor.href
+ return apiUri
+
App.createDataModel = (wrmlData) ->
new App.Entities.Model wrmlData
@@ -35,7 +35,6 @@
'click #main-toolbar-load-button' : 'handleMainToolbarLoad'
'click #main-toolbar-swagger-button' : 'handleMainToolbarSwagger'
-
onRender: ->
@self = @
@viewDocument = $.extend(true, {}, @model.attributes.model)
@@ -28,3 +28,25 @@
@Wrmldoc.module "ApiNotFoundApp.Show", (Show, App, Backbone, Marionette, $, _) ->
class Show.ApiNotFound extends App.Views.ItemView
template: "apiNotFound/show/apiNotFound_show"
+
+ events:
+ 'click #apiNotFound-new-button' : 'handleNewApi'
+
+ onRender: ->
+ @self = @
+ @apiNotFound = @model.attributes.model
+
+ onDomRefresh: ->
+ uri = @apiNotFound.requestUri
+ uri = App.getApiUri(uri)
+ queryParams = {}
+ queryParams.new = ""
+ uri = App.rewriteUri(uri, queryParams)
+
+ uriInput = $("#wrml-model-property-uri")
+ uriInput.val(uri)
+
+ handleNewApi: (e) ->
+ uriInput = $("#wrml-model-property-uri")
+ uri = uriInput.val()
+ App.openDocument(uri)
@@ -30,14 +30,11 @@
<div class="row">
- <div class="span3">
- </div>
-
<div class="span2">
<img id="apiNotFound-wormle" src="<%= @docroot %>img/wormle/facing-right-from-hole.png" />
</div>
- <div class="span5 apiNotFound-workflow">
+ <div class="span10 apiNotFound-workflow">
<div class="row">
@@ -46,44 +43,45 @@
<div class="popover right apiNotFound-speech-bubble">
<div class="arrow"></div>
<div class="popover-content">
- <p>
- Do you wish to design a new <strong><%= apiTitle %></strong>?
- </p>
+ <p>
+ Do you wish to design a new <strong>API</strong>?
+ </p>
+ </div>
</div>
-
</div>
</div>
<div class="row">
- <div class="span4 apiNotFound-workflow-element">
+ <div class="span8 apiNotFound-workflow-element">
<form class="form-horizontal apiNotFound-form" onsubmit="return false">
- <fieldset>
-
- <div class="control-group">
-
- <div class="controls">
- <button class="apiNotFound-form-button btn btn-inverse" type="button">Create New <%= apiTitle %></button>
- </div>
+ <fieldset class="wrml-form-fieldset">
+
+ <div class="control-group">
+
+ <label class="control-label" for="wrml-model-property-uri">URI</label>
+
+ <div class="controls">
+ <div class="input-append">
+ <input id="wrml-model-property-uri" class="wrml-model-property-input" type="text">
+ <button id="apiNotFound-new-button" class="btn btn-inverse" type="button">New</button>
+ </div>
+ </div>
</div>
</fieldset>
- </form>
- <div>
+ </form>
+ </div>
</div>
</div>
- <div class="span5">
- </div>
-
-
</div>
View
@@ -240,6 +240,14 @@ this.Wrmldoc = (function(Backbone, Marionette) {
}
return rewrittenUri;
};
+ App.getApiUri = function(documentUri) {
+ var apiUri, uriAnchor;
+ uriAnchor = document.createElement('a');
+ uriAnchor.href = documentUri;
+ uriAnchor.pathname = "";
+ apiUri = uriAnchor.href;
+ return apiUri;
+ };
App.createDataModel = function(wrmlData) {
return new App.Entities.Model(wrmlData);
};
@@ -1576,6 +1584,33 @@ this.Wrmldoc.module("ApiNotFoundApp.Show", function(Show, App, Backbone, Marione
ApiNotFound.prototype.template = "apiNotFound/show/apiNotFound_show";
+ ApiNotFound.prototype.events = {
+ 'click #apiNotFound-new-button': 'handleNewApi'
+ };
+
+ ApiNotFound.prototype.onRender = function() {
+ this.self = this;
+ return this.apiNotFound = this.model.attributes.model;
+ };
+
+ ApiNotFound.prototype.onDomRefresh = function() {
+ var queryParams, uri, uriInput;
+ uri = this.apiNotFound.requestUri;
+ uri = App.getApiUri(uri);
+ queryParams = {};
+ queryParams["new"] = "";
+ uri = App.rewriteUri(uri, queryParams);
+ uriInput = $("#wrml-model-property-uri");
+ return uriInput.val(uri);
+ };
+
+ ApiNotFound.prototype.handleNewApi = function(e) {
+ var uri, uriInput;
+ uriInput = $("#wrml-model-property-uri");
+ uri = uriInput.val();
+ return App.openDocument(uri);
+ };
+
return ApiNotFound;
})(App.Views.ItemView);
@@ -1641,19 +1676,11 @@ this.Wrmldoc.module("ApiNotFoundApp.Show", function(Show, App, Backbone, Marione
__out.push('\n\t\t\t</p>\t\n\t\t</div>\n\t\t');
}
- __out.push('\t\n\n\t</div>\n\n</section>\n\n<section id="apiNotFound">\n\t\n\t<div class="row">\n\n\t\t<div class="span3">\n\t\t</div>\n\n\t\t<div class="span2">\n\t\t\t<img id="apiNotFound-wormle" src="');
+ __out.push('\t\n\n\t</div>\n\n</section>\n\n<section id="apiNotFound">\n\t\n\t<div class="row">\n\n\t\t<div class="span2">\n\t\t\t<img id="apiNotFound-wormle" src="');
__out.push(__sanitize(this.docroot));
- __out.push('img/wormle/facing-right-from-hole.png" />\n\t\t</div>\n\n\t\t<div class="span5 apiNotFound-workflow">\n\n\t\t\t<div class="row">\n\t\t\t\n\t\t\t\t<div class="span4 apiNotFound-workflow-element">\n\t\t\t\t\t\n\t\t\t\t\t<div class="popover right apiNotFound-speech-bubble">\n\t\t\t\t\t\t<div class="arrow"></div>\t\t\t\t\t\t\n\t\t\t\t\t\t<div class="popover-content">\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tDo you wish to design a new <strong>');
-
- __out.push(__sanitize(apiTitle));
-
- __out.push('</strong>?\t\t\t\t\t\t\t\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t\n\t\t\t\t</div>\n\t\t\t\n\t\t\t</div>\n\n\t\t\t<div class="row">\n\n\t\t\t\t<div class="span4 apiNotFound-workflow-element">\n\t\t\t\t\t\n\t\t\t\t\t<form class="form-horizontal apiNotFound-form" onsubmit="return false">\n\n\t\t\t\t\t\t<fieldset>\t\t\t\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t<div class="control-group">\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t<div class="controls">\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<button class="apiNotFound-form-button btn btn-inverse" type="button">Create New ');
-
- __out.push(__sanitize(apiTitle));
-
- __out.push('</button>\n\t\t\t\t\t\t\t\t</div>\t\n\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t</fieldset>\n\t\t\t\t\t</form>\t\t\n\n\t\t\t\t<div>\t\t\n\t\t\t\n\t\t\t</div>\n\n\t\t</div>\n\n\t\t<div class="span5">\n\t\t</div>\n\n\n\t</div>\n\n\n</section>\n');
+ __out.push('img/wormle/facing-right-from-hole.png" />\n\t\t</div>\n\n\t\t<div class="span10 apiNotFound-workflow">\n\n\t\t\t<div class="row">\n\t\t\t\n\t\t\t\t<div class="span4 apiNotFound-workflow-element">\n\t\t\t\t\t\n\t\t\t\t\t<div class="popover right apiNotFound-speech-bubble">\n\t\t\t\t\t\t<div class="arrow"></div>\t\t\t\t\t\t\n\t\t\t\t\t\t<div class="popover-content">\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\tDo you wish to design a new <strong>API</strong>?\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\n\t\t\t</div>\n\n\t\t\t<div class="row">\n\n\t\t\t\t<div class="span8 apiNotFound-workflow-element">\n\t\t\t\t\t\n\t\t\t\t\t<form class="form-horizontal apiNotFound-form" onsubmit="return false">\n\n\t\t\t\t\t\t<fieldset class="wrml-form-fieldset">\n\n\t\t\t\t\t\t\t<div class="control-group">\n\n\t\t\t\t\t\t\t\t<label class="control-label" for="wrml-model-property-uri">URI</label>\n\n\t\t\t\t\t\t\t\t<div class="controls">\n\t\t\t\t\t\t\t\t\t<div class="input-append">\n\t\t\t\t\t\t\t\t\t\t<input id="wrml-model-property-uri" class="wrml-model-property-input" type="text">\n\t\t\t\t\t\t\t\t\t\t<button id="apiNotFound-new-button" class="btn btn-inverse" type="button">New</button>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t</fieldset>\n\n\t\t\t\t\t</form>\n\t\t\t\t</div>\n\t\t\t\n\t\t\t</div>\n\n\t\t</div>\n\n\t</div>\n\n\n</section>\n');
}).call(this);
Oops, something went wrong.

0 comments on commit 4a0f09d

Please sign in to comment.