73
73
</p >
74
74
<!-- text property input -->
75
75
<div
76
- v-if =" selectedPropertyToAddIsTextValue || addRelationBy === 'url'"
76
+ v-if =" ( selectedPropertyToAddIsTextValue || addRelationBy === 'url') && !selectedPropertyToAddIsVersionIdentifier "
77
77
class =" add-property-field" >
78
78
<!-- if it is a text input type, show the following -->
79
79
<div class =" add-property__input-type" >
117
117
</div >
118
118
</div >
119
119
</div >
120
+
121
+ <!-- Version Identifier input - special handling for complex object -->
122
+ <div
123
+ v-else-if =" selectedPropertyToAddIsVersionIdentifier"
124
+ class =" add-property-field" >
125
+ <div class =" add-property__input-type" >
126
+ <div class =" add-property__select-type" >
127
+ <div class =" field is-expanded" >
128
+ <h3 class =" subtitle is-6" >
129
+ {{ editingVersionIdentifierIndex >= 0 ? 'Edit Version Identifier' : 'Enter Version Identifier Information' }}
130
+ </h3 >
131
+
132
+ <!-- Display existing version identifiers -->
133
+ <div v-if =" versionIdentifiers.length > 0"
134
+ class =" field" >
135
+ <label class =" label" >Current Version Identifiers</label >
136
+ <div class =" box"
137
+ v-for =" (identifier, index) in versionIdentifiers"
138
+ :key =" index"
139
+ :class =" { 'has-background-info-light': editingVersionIdentifierIndex === index }" >
140
+ <div class =" columns is-vcentered" >
141
+ <div class =" column" >
142
+ <p ><strong >Value:</strong > {{ identifier.identifierValue }}</p >
143
+ <p ><strong >Name:</strong > {{ identifier.identifierName['@value'] }}</p >
144
+ <p ><strong >Type:</strong > {{ identifier.identifierType }}</p >
145
+ </div >
146
+ <div class =" column is-narrow" >
147
+ <div class =" buttons" >
148
+ <button
149
+ class =" button is-small is-info"
150
+ @click =" editVersionIdentifier(index)"
151
+ :disabled =" editingVersionIdentifierIndex >= 0 && editingVersionIdentifierIndex !== index" >
152
+ {{ editingVersionIdentifierIndex === index ? 'Editing...' : 'Edit' }}
153
+ </button >
154
+ <button
155
+ class =" button is-small is-danger"
156
+ @click =" removeVersionIdentifier(index)"
157
+ :disabled =" editingVersionIdentifierIndex >= 0" >
158
+ Remove
159
+ </button >
160
+ </div >
161
+ </div >
162
+ </div >
163
+ </div >
164
+ </div >
165
+
166
+ <!-- Reused form for both adding and editing -->
167
+ <div class =" field" >
168
+ <label class =" label" >Identifier Value Code</label >
169
+ <div class =" control" >
170
+ <input
171
+ class =" input"
172
+ v-model =" versionIdentifierData.identifierValue" >
173
+ </div >
174
+ </div >
175
+
176
+ <div class =" field" >
177
+ <label class =" label" >Identifier Type Name</label >
178
+ <PropertyString
179
+ :key =" tempKey"
180
+ ref =" identifierNameInput"
181
+ index =" null"
182
+ expandedProperty =" identifierName"
183
+ :langString =" true"
184
+ :range =" ['http://www.w3.org/2000/01/rdf-schema#langString']"
185
+ :newProperty =" true"
186
+ :profile =" profile"
187
+ :addSingle =" true"
188
+ :options =" null"
189
+ :overrideUpdate =" true"
190
+ :propertyValue =" versionIdentifierData.identifierName"
191
+ :customProperty =" true"
192
+ @updatePropertyString =" updateVersionIdentifierName" />
193
+ </div >
194
+
195
+ <div class =" field" >
196
+ <label class =" label" >Identifier Type</label >
197
+ <div class =" control" >
198
+ <input
199
+ class =" input"
200
+ v-model =" versionIdentifierData.identifierType" >
201
+ </div >
202
+ </div >
203
+
204
+ <div class =" field is-grouped" >
205
+ <div class =" control" >
206
+ <button
207
+ class =" button is-primary"
208
+ @click =" editingVersionIdentifierIndex >= 0 ? saveVersionIdentifierEdit() : addVersionIdentifier()"
209
+ :disabled =" !canAddVersionIdentifier" >
210
+ {{ editingVersionIdentifierIndex >= 0 ? 'Save Changes' : 'Add Version Identifier' }}
211
+ </button >
212
+ </div >
213
+ <div class =" control"
214
+ v-if =" editingVersionIdentifierIndex >= 0" >
215
+ <button
216
+ class =" button"
217
+ @click =" cancelVersionIdentifierEdit()" >
218
+ Cancel Edit
219
+ </button >
220
+ </div >
221
+ </div >
222
+ </div >
223
+ </div >
224
+ </div >
225
+ </div >
226
+
120
227
<!-- non text value input: create new, search, or url -->
121
228
<div
122
229
v-else-if =" selectedPropertyToAdd !== '' && !selectedPropertyToAddIsTextValue"
@@ -312,7 +419,15 @@ export default {
312
419
limitedTypes: [],
313
420
limitedConcepts: [],
314
421
createNewLevelNameModal: false ,
315
- newLevelName: ' '
422
+ newLevelName: ' ' ,
423
+ versionIdentifiers: [],
424
+ versionIdentifierData: {
425
+ identifierValue: ' ' ,
426
+ identifierName: {},
427
+ identifierType: ' '
428
+ },
429
+ tempKey: 0 ,
430
+ editingVersionIdentifierIndex: - 1
316
431
};
317
432
},
318
433
mounted : function () {
@@ -323,6 +438,11 @@ export default {
323
438
}
324
439
},
325
440
computed: {
441
+ canAddVersionIdentifier () {
442
+ return this .versionIdentifierData .identifierValue &&
443
+ this .versionIdentifierData .identifierName && this .versionIdentifierData .identifierName [' @value' ] &&
444
+ this .versionIdentifierData .identifierType ;
445
+ },
326
446
queryParams () {
327
447
return this .$store .getters [' editor/queryParams' ];
328
448
},
@@ -428,6 +548,9 @@ export default {
428
548
if (range .toLowerCase ().indexOf (" level" ) !== - 1 && this .profile [property][" add" ] !== " checkedOptions" ) {
429
549
return false ;
430
550
}
551
+ if (range .toLowerCase ().indexOf (" https://purl.org/ctdl/terms/IdentifierValue" ) !== - 1 ) {
552
+ return false ;
553
+ }
431
554
let urlProperties = [
432
555
" https://purl.org/ctdlasn/terms/knowledgeEmbodied" ,
433
556
" https://purl.org/ctdlasn/terms/skillEmbodied" ,
@@ -444,6 +567,10 @@ export default {
444
567
return false ;
445
568
}
446
569
return true ;
570
+ },
571
+ selectedPropertyToAddIsVersionIdentifier : function () {
572
+ let property = this .selectedPropertyToAdd [" value" ] ? this .selectedPropertyToAdd [" value" ] : " " ;
573
+ return property === " https://purl.org/ctdl/terms/versionIdentifier" ;
447
574
}
448
575
},
449
576
methods: {
@@ -501,6 +628,73 @@ export default {
501
628
}
502
629
}
503
630
});
631
+ },
632
+ editVersionIdentifier (index ) {
633
+ this .editingVersionIdentifierIndex = index;
634
+ const identifier = this .versionIdentifiers [index];
635
+
636
+ // Populate the form with existing data
637
+ this .versionIdentifierData = {
638
+ identifierValue: identifier .identifierValue ,
639
+ identifierName: {... identifier .identifierName },
640
+ identifierType: identifier .identifierType
641
+ };
642
+
643
+ // Force PropertyString component to re-render with new data
644
+ this .tempKey ++ ;
645
+ },
646
+ saveVersionIdentifierEdit () {
647
+ if (this .canAddVersionIdentifier && this .editingVersionIdentifierIndex >= 0 ) {
648
+ // Update the existing identifier
649
+ this .versionIdentifiers [this .editingVersionIdentifierIndex ] = {... this .versionIdentifierData };
650
+ this .cancelVersionIdentifierEdit ();
651
+ }
652
+ },
653
+ cancelVersionIdentifierEdit () {
654
+ this .editingVersionIdentifierIndex = - 1 ;
655
+ // Clear the form
656
+ this .clearVersionIdentifierForm ();
657
+ },
658
+ // Modify existing addVersionIdentifier to handle edit mode
659
+ addVersionIdentifier () {
660
+ if (this .canAddVersionIdentifier ) {
661
+ if (this .editingVersionIdentifierIndex >= 0 ) {
662
+ // This is actually an edit save
663
+ this .saveVersionIdentifierEdit ();
664
+ } else {
665
+ // Original add logic
666
+ this .versionIdentifiers .push ({... this .versionIdentifierData });
667
+ this .clearVersionIdentifierForm ();
668
+ }
669
+ }
670
+ this .emitVersionIdentifiers ();
671
+ },
672
+ removeVersionIdentifier (index ) {
673
+ this .versionIdentifiers .splice (index, 1 );
674
+ this .emitVersionIdentifiers ();
675
+ },
676
+ clearVersionIdentifierForm () {
677
+ this .versionIdentifierData = {
678
+ identifierValue: ' ' ,
679
+ identifierName: {},
680
+ identifierType: ' '
681
+ };
682
+
683
+ this .tempKey = Date .now ();
684
+ },
685
+ updateVersionIdentifierName (value ) {
686
+ this .versionIdentifierData .identifierName = value;
687
+ },
688
+ emitVersionIdentifiers () {
689
+ const versionId = this .versionIdentifiers .map ((x ) => {
690
+ return {
691
+ " https://purl.org/ctdl/terms/identifierValueCode" : x .identifierValue ,
692
+ " https://purl.org/ctdl/terms/identifierTypeName" : x .identifierName ,
693
+ " https://purl.org/ctdl/terms/identifierType" : x .identifierType
694
+ };
695
+ });
696
+ // Emit the value through the property-string-updated event
697
+ this .updatePropertyString (versionId);
504
698
}
505
699
},
506
700
watch: {
0 commit comments