project-creation-window.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div class="project-creation-window">
  3. <h1 class="title">Create Project</h1>
  4. <div class="content">
  5. <text-input placeholder="Name"
  6. v-model="name"
  7. :error="nameError"
  8. @clearError="nameError = false">
  9. Name
  10. </text-input>
  11. <textarea-input placeholder="Description"
  12. v-model="description"
  13. :error="descriptionError"
  14. @clearError="descriptionError = false">
  15. Description
  16. </textarea-input>
  17. <select-input :values="models"
  18. v-model="model">
  19. Model
  20. </select-input>
  21. </div>
  22. <div class="footer">
  23. <button-input @click="create" type="primary">
  24. Create Project
  25. </button-input>
  26. <button-input @click="$emit('cancel', null)">
  27. Cancel
  28. </button-input>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import TextInput from "@/components/base/text-input";
  34. import TextareaInput from "@/components/base/textarea-input";
  35. import SelectInput from "@/components/base/select-input";
  36. import ButtonInput from "@/components/base/button-input";
  37. export default {
  38. name: "project-creation-window",
  39. components: {ButtonInput, SelectInput, TextareaInput, TextInput},
  40. props: ['status', 'socket'],
  41. data: function() {
  42. return {
  43. name: '',
  44. nameError: false,
  45. description: '',
  46. descriptionError: false,
  47. model: null
  48. }
  49. },
  50. computed: {
  51. models: function() {
  52. let result = [];
  53. for (let o in this.status.models) {
  54. result.push({
  55. 'name': this.status.models[o].name,
  56. 'value': this.status.models[o].id
  57. });
  58. }
  59. return result;
  60. }
  61. },
  62. created: function() {
  63. this.model = this.models[0].value;
  64. },
  65. methods: {
  66. create: function() {
  67. this.nameError = !this.name;
  68. this.descriptionError = !this.description;
  69. if (this.nameError || this.descriptionError)
  70. return;
  71. this.socket.add(
  72. 'projects',
  73. {
  74. status: 'create',
  75. name: this.name,
  76. description: this.description,
  77. model: this.model
  78. }
  79. );
  80. this.$emit('cancel', null);
  81. }
  82. }
  83. }
  84. </script>
  85. <style scoped>
  86. .project-creation-window {
  87. display: flex;
  88. flex-direction: column;
  89. }
  90. .title {
  91. margin: 0;
  92. padding: 2rem;
  93. border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  94. flex-grow: 0;
  95. display: flex;
  96. }
  97. .content {
  98. overflow: auto;
  99. padding: 1rem;
  100. flex-grow: 1;
  101. }
  102. .content > * {
  103. margin-bottom: 0.6rem;
  104. }
  105. /deep/ .content textarea {
  106. height: 4rem;
  107. }
  108. .footer {
  109. flex-grow: 0;
  110. padding: 2rem;
  111. display: flex;
  112. flex-direction: row;
  113. justify-content: flex-end;
  114. }
  115. .footer > * {
  116. margin-left: 0.5rem;
  117. }
  118. .cancel {
  119. cursor: pointer;
  120. }
  121. </style>