<span ng-if='!definition.mclassdef'>
in <entity-link mentity='definition.mmodule' />
</span>
+ <div class='btn-bar'>
+ <button class='btn btn-link' aria-expanded='false'
+ data-target='#{{codeId}}' ng-click='loadCardCode()'
+ aria-controls='{{codeId}}'>
+ <span class='glyphicon glyphicon-console'
+ title='Show code' />
+ </button>
+ </div>
</h5>
+ <div id='{{codeId}}' class='collapse'>
+ <pre ng-bind-html='code' />
+ </div>
<entity-location mentity='definition' />
</div>
</div>
});
};
+ this.loadEntityDefs = function() {
+ Model.loadEntityDefs($routeParams.id,
+ function(data) {
+ $scope.defs = data;
+ }, function(err) {
+ $scope.error = err;
+ });
+ };
+
this.loadEntityCode = function() {
Model.loadEntityCode($routeParams.id,
function(data) {
definition: '=',
focus: '='
},
+ templateUrl: '/directives/entity/defcard.html',
link: function ($scope, element, attrs) {
- $scope.$watch("definition", function() {
- /*.loadEntityDefs($scope.definition.full_name,
- function(data) {
- $scope.mentity = data;
- }, function(err) {
- $scope.error = err;
- });
- Model.loadEntityCode($scope.definition.full_name,
- function(data) {
- $scope.code = data;
- }, function(err) {
- $scope.error = err;
- });*/
- });
- },
- templateUrl: '/directives/entity/defcard.html'
+ $scope.codeId = 'code_' + $scope.definition.full_name.replace(/[^a-zA-Z0-9]/g, '_');
+ $scope.loadCardCode = function() {
+ if(!$scope.code) {
+ Model.loadEntityCode($scope.definition.full_name,
+ function(data) {
+ $scope.code = data;
+ setTimeout(function() { // smooth collapse
+ $('#' + $scope.codeId).collapse('show')
+ }, 1);
+ }, function(err) {
+ $scope.code = err;
+ });
+ } else {
+ if($('#' + $scope.codeId).hasClass('in')) {
+ $('#' + $scope.codeId).collapse('hide');
+ } else {
+ $('#' + $scope.codeId).collapse('show');
+ }
+ }
+ };
+ }
};
}])
})();
.error(cbErr);
},
+ loadEntityDefs: function(id, cb, cbErr) {
+ $http.get(apiUrl + '/defs/' + id)
+ .success(cb)
+ .error(cbErr);
+ },
+
loadEntityCode: function(id, cb, cbErr) {
$http.get(apiUrl + '/code/' + id)
.success(cb)
/* ui */
+.btn-bar { margin-top: -5px; float: right }
+.btn-bar .btn { padding: 5px 10px; }
+
entity-list .btn-filter {
visibility: hidden;
}
</a>
</li>
<li role='presentation'>
+ <a data-toggle='tab' data-target='#all_props'>
+ <span class='glyphicon glyphicon-tags'/> All properties
+ </a>
+ </li>
+ <li role='presentation'>
<a data-toggle='tab' role='tab' data-target='#linearization' aria-controls='linearization' ng-click='entityCtrl.loadEntityLinearization()'>
<span class='glyphicon glyphicon-arrow-down'/> Linearization
</a>
list-entities='mentity.redef_mproperties'
list-object-filter='{is_init: "!true"}' />
</div>
+ <div role='tabpanel' class='tab-pane fade' id='all_props'>
+ <entity-list list-title='All properties' list-entities='mentity.all_mproperties'
+ list-object-filter='{}' />
+ </div>
<div role='tabpanel' class='tab-pane fade' id='linearization'>
<entity-linearization
list-title='Class definitions'
</div>
<ul class='nav nav-tabs'>
- <li class='active'>
+ <li role='presentation' class='active'>
<a data-toggle='tab' data-target='#doc'>
<span class='glyphicon glyphicon-book'/> Doc
</a>
</li>
- <li>
+ <li role='presentation'>
<a data-toggle='tab' data-target='#code' ng-click="entityCtrl.loadEntityCode()">
<span class='glyphicon glyphicon-console'/> Code
</a>
</li>
+ <li role='presentation'>
+ <a data-toggle='tab' data-target='#defs' ng-click="entityCtrl.loadEntityDefs()">
+ <span class='glyphicon glyphicon-asterisk'/> Class definitions
+ </a>
+ </li>
</ul>
<div class='tab-content'>
</div>
</div>
</div>
+ <div role='tabpanel' class='tab-pane fade' id='defs'>
+ <entity-list list-title='Class definitions' list-entities='defs'
+ list-object-filter='{}' />
+ </div>
</div>
</div>
use("/code/:id", new APIEntityCode(model, mainmodule, modelbuilder))
use("/uml/:id", new APIEntityUML(model, mainmodule))
use("/linearization/:id", new APIEntityLinearization(model, mainmodule))
+ use("/defs/:id", new APIEntityDefs(model, mainmodule))
end
end
end
end
+# List definitions of a MEntity.
+#
+# Example: `GET /defs/core::Array`
+class APIEntityDefs
+ super APIHandler
+
+ redef fun get(req, res) do
+ var mentity = mentity_from_uri(req, res)
+ var arr = new JsonArray
+ if mentity isa MModule then
+ for mclassdef in mentity.mclassdefs do arr.add mclassdef
+ else if mentity isa MClass then
+ for mclassdef in mentity.mclassdefs do arr.add mclassdef
+ else if mentity isa MClassDef then
+ for mpropdef in mentity.mpropdefs do arr.add mpropdef
+ else if mentity isa MProperty then
+ for mpropdef in mentity.mpropdefs do arr.add mpropdef
+ else
+ res.error 404
+ return
+ end
+ res.json arr
+ end
+end
+
# Return a UML representation of MEntity.
#
# Example: `GET /entity/core::Array/uml`