Skip to content
Permalink
Browse files

Implemented base functionality of API Not Found View.

  • Loading branch information
markmasse committed Nov 19, 2015
1 parent 5ebfb07 commit 4a0f09d01df35def169655327f55f6db7ce0de6c
@@ -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;
}
}

}

Some generated files are not rendered by default. Learn more.

Large diffs are not rendered by default.

@@ -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;
}
}

}

Some generated files are not rendered by default. Learn more.

@@ -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>


Some generated files are not rendered by default. Learn more.

0 comments on commit 4a0f09d

Please sign in to comment.
You can’t perform that action at this time.