New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DSP-652 FIX: Boolean add button #182
Changes from 5 commits
d9492ea
1ebce26
77238b3
73f7c17
5e77300
94ab6a8
40cb19e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { animate, state, style, transition, trigger } from '@angular/animations'; | ||
import { | ||
Component, | ||
Input, | ||
OnDestroy, | ||
OnInit, | ||
ViewChild | ||
} from '@angular/core'; | ||
import { PermissionUtil, ReadResource, SystemPropertyDefinition } from '@dasch-swiss/dsp-js'; | ||
import { CardinalityUtil, PermissionUtil, ReadResource, SystemPropertyDefinition } from '@dasch-swiss/dsp-js'; | ||
import { Subscription } from 'rxjs'; | ||
import { AddValueComponent } from '../../operations/add-value/add-value.component'; | ||
import { DisplayEditComponent } from '../../operations/display-edit/display-edit.component'; | ||
|
@@ -53,7 +52,6 @@ export class PropertyViewComponent implements OnInit, OnDestroy { | |
addButtonIsVisible: boolean; // used to toggle add value button | ||
addValueFormIsVisible: boolean; // used to toggle add value form field | ||
propID: string; // used in template to show only the add value form of the corresponding value | ||
readOnlyProp: boolean; // used in template to not show an "add" button for properties we do not yet have a way to create/edit | ||
|
||
valueOperationEventSubscription: Subscription; | ||
|
||
|
@@ -86,10 +84,8 @@ export class PropertyViewComponent implements OnInit, OnDestroy { | |
* Called from the template when the user clicks on the add button | ||
*/ | ||
showAddValueForm(prop: PropertyInfoValues) { | ||
|
||
this.propID = prop.propDef.id; | ||
this.addValueFormIsVisible = true; | ||
|
||
} | ||
|
||
/** | ||
|
@@ -100,4 +96,24 @@ export class PropertyViewComponent implements OnInit, OnDestroy { | |
this.addButtonIsVisible = true; | ||
this.propID = undefined; | ||
} | ||
|
||
/** | ||
* Given a resource property, check if an add button should be displayed under the property values | ||
* | ||
* @param prop the resource property | ||
*/ | ||
addValueIsAllowed(prop: PropertyInfoValues): boolean { | ||
const isAllowed = CardinalityUtil.createValueForPropertyAllowed( | ||
prop.propDef.id, prop.values.length, this.parentResource.entityInfo.classes[this.parentResource.type]); | ||
|
||
// check if: | ||
// cardinality allows for a value to be added | ||
// value component does not already have an add value form open | ||
// user has write permissions | ||
if (isAllowed && this.propID !== prop.propDef.id && this.addButtonIsVisible) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "value component does not already have an add value form open"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, I get it now :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can just return the whole expression, no need for an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. noob code fixed in 40cb19e |
||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the condition contain a property IRI from the anything test project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I get it: but then this should be more generic than
'http://0.0.0.0:3333/ontology/0001/anything/v2#hasRichtext'
, you could use the gui eleThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should integrate the XML / CKeditor functionality asap, so this becomes unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I'll make the small change to use the gui element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 94ab6a8