Skip to content

Commit

Permalink
add endpoint and ui example.
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman committed Aug 22, 2016
1 parent 13538b0 commit a0e978b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ vendor
# Ignore log files, but track the log README
*.log

!customs/endpoints/_example.php
customs/extensions/*
!customs/extensions/.gitignore
!customs/extensions/_example/
Expand Down
5 changes: 5 additions & 0 deletions app/core/BaseUIView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
define(['core/UIView'], function(UIView) {
return UIView.extend({
prefix: 'customs/uis/'
});
});
15 changes: 15 additions & 0 deletions customs/endpoints/_example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Directus\Bootstrap;
use Directus\View\JsonView;

// Slim App
$app = Bootstrap::get('app');

// Simple GET endpoint example
$app->get('/example', function() {
return JsonView::render([
'item 1',
'item 2'
]);
});
3 changes: 2 additions & 1 deletion customs/uis/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*
!.gitignore
!.gitignore
!_example
29 changes: 29 additions & 0 deletions customs/uis/_example/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
define(['core/UIComponent', 'core/BaseUIView'], function(UIComponent, UIView) {
var charactersLimit = 100;
var Input = UIView.extend({
template: '_example/templates/input',
events: {
'keyup textarea': 'updateCount'
},
updateCount: function(event) {
var textLength = event.currentTarget.value.length;
var textRemaining = charactersLimit - textLength;
this.$el.find('#count').text(textRemaining);
},
serialize: function() {
return {
maxLength: charactersLimit,
charactersRemaining: charactersLimit
}
}
});

var Component = UIComponent.extend({
id: 'textlimit',
dataTypes: ['TEXT'],
Input: Input
});


return Component;
});
2 changes: 2 additions & 0 deletions customs/uis/_example/templates/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<textarea maxLength="{{maxLength}}"></textarea>
<span id="count">{{charactersRemaining}}</span>

0 comments on commit a0e978b

Please sign in to comment.