@@ -135,9 +135,10 @@ define([
135135 try {
136136 var importMeta = JSON . parse ( decodeURIComponent ( this . metadata . options . find ( x => x . id == 'vp_importMeta' ) . value ) ) ;
137137 importMeta && importMeta . forEach ( ( obj , i ) => {
138- var tagTr = $ ( `<tr><td><input id="vp_library${ i } " type="text" class="vp-input m vp-add-library" placeholder="library name" required value="${ obj . library . toLowerCase ( ) } "/></td>
139- <td><input id="vp_alias${ i } " type="text" class="vp-input m vp-add-alias" placeholder="as" value="${ obj . alias } "/></td>
140- <td><input type="button" class="vp-remove-option w100" style="width:100%;" value="x"></td></tr>` ) ;
138+ // var tagTr = $(`<tr><td><input id="vp_library${i}" type="text" class="vp-input m vp-add-library" placeholder="library name" required value="${obj.library.toLowerCase()}"/></td>
139+ // <td><input id="vp_alias${i}" type="text" class="vp-input m vp-add-alias" placeholder="as" value="${obj.alias}"/></td>
140+ // <td><input type="button" class="vp-remove-option w100" style="width:100%;" value="x"></td></tr>`);
141+ var tagTr = $ ( that . renderLibraryRow ( i , obj . library . toLowerCase ( ) , obj . alias ) ) ;
141142
142143 $ ( this . wrapSelector ( "#vp_tblImport tr:last" ) ) . before ( tagTr ) ;
143144 } ) ;
@@ -148,10 +149,11 @@ define([
148149 // <option value="as">as</option>
149150 // <option value="import">import</option>
150151 // </select>
151- var tagTr = $ ( `<tr><td><input id="vp_library${ i } " type="text" class="vp-input m vp-add-library" placeholder="library name" required value="${ package . library . toLowerCase ( ) } "/></td>
152- <td><input id="vp_alias${ i } " type="text" class="vp-input m vp-add-alias" placeholder="as" value="${ package . alias } "/></td>
153- <td><input type="button" class="vp-remove-option w100" style="width:100%;" value="x"></td></tr>` ) ;
154-
152+ // var tagTr = $(`<tr><td><input id="vp_library${i}" type="text" class="vp-input m vp-add-library" placeholder="library name" required value="${package.library.toLowerCase()}"/></td>
153+ // <td><input id="vp_alias${i}" type="text" class="vp-input m vp-add-alias" placeholder="as" value="${package.alias}"/></td>
154+ // <td><input type="button" class="vp-remove-option w100" style="width:100%;" value="x"></td></tr>`);
155+ var tagTr = $ ( that . renderLibraryRow ( i , package . library . toLowerCase ( ) , package . alias ) ) ;
156+
155157 $ ( this . wrapSelector ( "#vp_tblImport tr:last" ) ) . before ( tagTr ) ;
156158
157159 // add to package input
@@ -168,9 +170,12 @@ define([
168170
169171 // 라이브러리 추가
170172 $ ( this . wrapSelector ( '#vp_addLibrary' ) ) . click ( function ( ) {
171- var tagTr = $ ( `<tr><td><input type="text" class="vp-add-library" placeholder="library name" required/></td>
172- <td><input type="text" class="vp-input m vp-add-alias" placeholder="alias"/></td>
173- <td><input type="button" class="vp-remove-option w100" style="width:100%;" value="x"></td></tr>` ) ;
173+ var libsLength = $ ( that . wrapSelector ( "#vp_tblImport tr:not(:first):not(:last)" ) ) . length ;
174+
175+ // var tagTr = $(`<tr><td><input type="text" class="vp-add-library" placeholder="library name" required/></td>
176+ // <td><input type="text" class="vp-input m vp-add-alias" placeholder="alias"/></td>
177+ // <td><input type="button" class="vp-remove-option w100" style="width:100%;" value="x"></td></tr>`);
178+ var tagTr = $ ( that . renderLibraryRow ( libsLength , '' , '' ) ) ;
174179
175180 $ ( that . wrapSelector ( "#vp_tblImport tr:last" ) ) . before ( tagTr ) ;
176181 } ) ;
@@ -195,6 +200,24 @@ define([
195200
196201 }
197202
203+ ImportPackage . prototype . renderLibraryRow = function ( idx , libraryName , aliasName ) {
204+ var tag = new sb . StringBuilder ( ) ;
205+ /**
206+ * <td><input id="vp_library${i}" type="text" class="vp-input m vp-add-library" placeholder="library name" required value="${package.library.toLowerCase()}"/></td>
207+ <td><input id="vp_alias${i}" type="text" class="vp-input m vp-add-alias" placeholder="as" value="${package.alias}"/></td>
208+ <td><input type="button" class="vp-remove-option w100" style="width:100%;" value="x"></td></tr>
209+ */
210+ tag . append ( '<tr>' ) ;
211+ tag . appendFormat ( '<td><input id="{0}" type="text" class="{1}" placeholder="{2}" required value="{3}"/></td>'
212+ , 'vp_library' + idx , 'vp-input m vp-add-library' , 'Type library name' , libraryName ) ;
213+ tag . appendFormat ( '<td><input id="{0}" type="text" class="{1}" placeholder="{2}" value="{3}"/></td>'
214+ , 'vp_alias' + idx , 'vp-input m vp-add-alias' , 'Type alias' , aliasName ) ;
215+ // tag.appendFormat('<td><input type="button" class="{0}" style="width:100%;" value="{1}"></td>', 'vp-remove-option w100', 'x');
216+ tag . appendFormat ( '<td><i class="{0} {1}"></i></td>' , 'fa fa-close' , 'vp-remove-option w100 vp-cursor' ) ;
217+ tag . append ( '</tr>' ) ;
218+ return tag . toString ( ) ;
219+ }
220+
198221 /**
199222 * 코드 생성
200223 * @param {boolean } addCell 셀 추가 여부
0 commit comments