@@ -44,6 +44,12 @@ $(function() {
44
44
$ ( 'form#detail' ) . submit ( e => {
45
45
e . preventDefault ( ) ;
46
46
47
+ if ( $ ( "#btnAdd" ) . text ( ) == 'Cancel' ) {
48
+ changeBtnContext ( '#btnAdd' , '1' ) ;
49
+ return ;
50
+ }
51
+
52
+
47
53
const inputText = document . querySelectorAll ( '.text-validate' ) ;
48
54
49
55
inputText . forEach ( item => {
@@ -87,45 +93,51 @@ $(function() {
87
93
}
88
94
} ) ;
89
95
90
- let currentRowIndex = - 1 ;
91
-
92
- const tableProjectDetail = this . querySelector ( '#table-project-detail' ) ;
96
+
93
97
94
- tableProjectDetail . addEventListener ( 'click' , e => {
95
- parentTag = $ ( e . target ) . parent ( ) ;
98
+ let currentRowIndex = - 1 ;
96
99
97
- console . log ( parentTag ) ;
100
+ const detail = this . querySelector ( '#project-detail-body' ) ;
98
101
99
- if (
100
- parentTag . prop ( 'tagName' ) == 'TR' &&
101
- ! parentTag . hasClass ( 'tr-heading' )
102
- ) {
103
- const lastRow = `#table-project-detail tr[alt=${ currentRowIndex } ]` ;
104
- console . log ( lastRow ) ;
102
+ detail . addEventListener ( 'click' , e => {
103
+
104
+ console . log ( e . target . tagName ) ;
105
+
106
+ console . log ( e . target . className )
107
+
108
+ console . log ( e )
105
109
106
- $ ( lastRow ) . removeClass ( 'selected-row' ) ;
107
110
108
- $ ( tableProjectDetail ) ;
111
+ if ( e . target . tagName == 'A' ) {
112
+ if ( e . target . rel == 'edit' ) {
113
+ getProjectItemForEdit ( $ ( e . target ) . attr ( 'alt' ) ) ;
114
+ } else if ( e . target . rel == 'delete' ) {
109
115
110
- currentRowIndex = $ ( e . target )
111
- . parent ( )
112
- . attr ( 'alt' ) ;
113
- $ ( e . target )
114
- . parent ( )
115
- . addClass ( 'selected-row' ) ;
116
+ }
116
117
}
118
+
119
+
120
+
117
121
} ) ;
118
122
119
- $ ( '#table-project-detail' ) . click ( e => { } ) ;
123
+
120
124
121
125
$ ( '.select2' ) . select2 ( {
122
126
theme : 'classic' ,
123
127
width : 'resolve' ,
124
128
} ) ;
125
129
126
130
/* Add property detail to project */
131
+
132
+
133
+
134
+
135
+
127
136
} ) ;
128
137
138
+
139
+
140
+
129
141
function addProjectDetail ( ) {
130
142
const type = document . querySelector ( '#propertyType' ) ;
131
143
const code = document . querySelector ( '#code' ) ;
@@ -148,16 +160,28 @@ function addProjectDetail() {
148
160
const rowCount = $ ( '#table-project-detail td' ) . closest ( 'tr' ) . length + 1 ;
149
161
150
162
const row = `<tr class="detail-row" alt=${ rowCount - 1 } ><td>${ rowCount } </td>
151
- <td><div alt='${ type . value } '></div>${ stType } </td>
152
- <td>${ code . value } </td>
153
- <td>${ description . value } </td>
154
- <td>${ no . value } </td>
155
- <td>${ st . value } </td>
156
- <td>${ propAttribute } </td>
157
- <td>${ cost . value } </td>
158
- <td>${ price . value } </td>
159
- <td>${ free . value } </td>
160
- <td><div alt='${ publish . value } '></div>${ stPublish } </td>
163
+ <td alt='${ type . value } '>${ stType } </td>
164
+ <td alt='${ code . value } '>${ code . value } </td>
165
+ <td alt='${ description . value } '>${ description . value } </td>
166
+ <td alt='${ no . value } '>${ no . value } </td>
167
+ <td alt='${ st . value } '>${ st . value } </td>
168
+ <td alt='${ $ ( '#attribute' ) . val ( ) } '>${ propAttribute } </td>
169
+ <td alt='${ cost . value } '>${ cost . value } </td>
170
+ <td alt='${ price . value } '>${ price . value } </td>
171
+ <td alt='${ free . value } '>${ free . value } </td>
172
+ <td alt='${
173
+ publish . value
174
+ } ' class='pro-detail-publish'>${ stPublish } </td>
175
+ <td>
176
+ <a alt=${ rowCount - 1 } rel="edit" href="#" class="btn btn-primary edit">Edit</a>
177
+
178
+ </td>
179
+ <td>
180
+ <a alt=${ rowCount - 1 } rel="delete" href="#" class="btn btn-danger delete">Delete</a>
181
+ </td>
182
+
183
+
184
+
161
185
` ;
162
186
163
187
$ ( '#project-detail-body' ) . append ( row ) ;
@@ -170,3 +194,14 @@ function addProjectDetail() {
170
194
$ ( '#tCost' ) . text ( tCost ) ;
171
195
$ ( '#tPrice' ) . text ( tPrice ) ;
172
196
}
197
+
198
+
199
+
200
+ function getProjectItemForEdit ( rowIndex ) {
201
+ let row = document . querySelector ( `.tr[alt="${ rowIndex } "]` ) ;
202
+ console . log ( row ) ;
203
+ }
204
+
205
+ function showPropertyPopup ( ) {
206
+
207
+ }
0 commit comments