PageRenderTime 68ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/web/admin/project.php

https://bitbucket.org/yoander/mtrack
PHP | 88 lines | 68 code | 17 blank | 3 comment | 2 complexity | af196f350a918ff87ce7fc96cc583e71 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0
  1. <?php # vim:ts=2:sw=2:et:
  2. /* For licensing and copyright terms, see the file named LICENSE */
  3. include '../../inc/common.php';
  4. MTrackACL::requireAnyRights('Projects', 'modify');
  5. mtrack_head("Administration - Projects");
  6. mtrack_admin_nav();
  7. $projects = json_encode(MTrackAPI::invoke('GET', '/project/')->result);
  8. echo <<<HTML
  9. <h1>Projects</h1>
  10. <p>
  11. Projects can be created to track development on a per-project or per-product
  12. basis. Components may be associated with a project, as well as a default
  13. email distribution address.
  14. </p>
  15. <script>
  16. $(document).ready(function() {
  17. var projects = new MTrackProjectCollection($projects);
  18. // $('#projlist').sortable();
  19. function show_edit(P) {
  20. var V = new MTrackProjectEditView({
  21. model: P
  22. });
  23. var is_new = P.isNew();
  24. V.show(function (model) {
  25. if (is_new) {
  26. projects.add(model, {at: projects.length});
  27. } else {
  28. render_list();
  29. }
  30. });
  31. };
  32. $('#projlist').on('click', 'a', function () {
  33. var P = $(this.parentElement).data('project');
  34. show_edit(P);
  35. });
  36. function addOne(P) {
  37. var li = $('<li/>');
  38. var a = $('<a href="#"/>');
  39. a.text(P.get('name'));
  40. li.append(a);
  41. li.data('project', P);
  42. li.appendTo('#projlist');
  43. }
  44. function render_list() {
  45. $('#projlist').empty();
  46. projects.each(function (P) {
  47. addOne(P);
  48. });
  49. }
  50. render_list();
  51. projects.bind('add', function (P) {
  52. addOne(P);
  53. });
  54. $('#newrepobtn').click(function () {
  55. var P = new MTrackProject;
  56. show_edit(P);
  57. });
  58. // Clear any text from the form when it hides
  59. $('#editdialog').on('hidden', function () {
  60. $('input', this).val('');
  61. $('div.alert', this).remove();
  62. $('#saveproj').off('click.saveproj');
  63. });
  64. });
  65. </script>
  66. <button id='newrepobtn' class='btn btn-primary'
  67. type='button'><i class='icon-plus icon-white'></i> New Project</button>
  68. <ul id='projlist' class='nav nav-pills nav-stacked'>
  69. </ul>
  70. HTML;
  71. mtrack_foot();