ManagedReference.extension.js 981 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
  2. var common = require('./ManagedReference.common.js');
  3. exports.preTransform = function (model) {
  4. transform(model);
  5. function transform(item) {
  6. if (item.children) item.children.forEach(function(i) {
  7. transform(i);
  8. });
  9. }
  10. return model;
  11. }
  12. exports.postTransform = function (model) {
  13. var type = model.type.toLowerCase();
  14. var category = common.getCategory(type);
  15. if (category == 'class') {
  16. var typePropertyName = common.getTypePropertyName(type);
  17. if (typePropertyName) {
  18. model[typePropertyName] = true;
  19. }
  20. if (model.children && model.children.length > 0) {
  21. model.isCollection = true;
  22. common.groupChildren(model, 'class');
  23. } else {
  24. model.isItem = true;
  25. }
  26. }
  27. return model;
  28. }