WAConfigurationEditor


Seaside-Components-Tools

Comment:



Hierarchy:

ProtoObject
Object
WAPresenter
WAComponent
WAConfigurationEditor

Summary:

instance variables:

configuration

methods:

instance class
accessing actions initialization rendering rendering visitors no messages

Detail:

instance variables:

configuration

instance methods:

accessing
configuration

	^ configuration
configuration: aConfiguration

	configuration _ aConfiguration
trailName

	^ configuration name

actions
done

	self answer
save

select: aConfiguration

	self call: (WAConfigurationEditor new configuration: aConfiguration)

initialization
initialize

	configuration _ WAConfiguration new

rendering
renderAncestryListFor: aConfiguration seen: aSet on: html

	aConfiguration ancestors isEmpty ifTrue: [^ self].
	
	html list: aConfiguration ancestors do:
		[:ea |
		self renderParent: ea on: html.
		(aSet includes: ea) ifFalse:
			[aSet add: ea.
			self renderAncestryListFor: ea seen: aSet on: html]].
renderAncestryOn: html

	html attributes style: 'border: 1px solid black; background: lightgrey'.
	html div: [
		html table: [
			html heading: 'Configuration Ancestors' level: 2.

			configuration potentialAncestors isEmpty ifFalse:
				[html text: 'Add ancestor: '.
				self renderParentSelectorOn: html].
			self renderAncestryListFor: configuration seen: Set new on: html]].
renderAttribute: anAttribute on: html

	html tableRow: [
		html tableData: (html labelForSelector: anAttribute key).
		html tableData: [
			(configuration valueForAttribute: anAttribute)
				ifNil: [self renderUnspecifiedAttribute: anAttribute on: html]
				ifNotNil: 
					[(configuration hasLocalValueForAttribute: anAttribute)
						ifTrue: [self renderOverridenAttribute: anAttribute on: html]
						ifFalse: [self renderInheritedAttribute: anAttribute on: html]]
		].
		self renderInheritanceForAttribute: anAttribute on: html]
renderContentOn: html

	html form: [
		self renderFormOn: html.
		
		html break.
		html submitButtonOn: #save of: self.
		html submitButtonOn: #done of: self.
	]
renderFormOn: html

	self renderAncestryOn: html.
	html break.
	html attributes style: 'border: 1px solid black'.
	html div: [
		html table: [
			configuration groupedAttributes
				do: [:assoc |
					html tableRowWith: [html heading: (html labelForSelector: assoc key) level: 3] span: 2.
					assoc value do:
						[:attr | self renderAttribute: attr on: html]]]]
renderInheritanceForAttribute: anAttribute on: html

	configuration inheritedValueAndSourceAt: anAttribute key do:
		[:value :source |
		(configuration hasLocalValueForAttribute: anAttribute)
			ifTrue:
				[html tableData: [
					html anchorWithAction: [configuration clearValueForAttribute: anAttribute] text: 'revert'.
					html text: ' to: ', value printString].
				html tableData: [
					html text: 'overriden from ', source name]]
			ifFalse:
				[html tableData: [html anchorWithAction: [configuration overrideAttribute: anAttribute] text: 'override'].
				html tableData: [html text: 'inherited from ', source name]].
		^ self].
	(configuration hasLocalValueForAttribute: anAttribute)
		ifTrue: [html tableData: [html anchorWithAction: [configuration clearValueForAttribute: anAttribute] text: 'clear']]
		ifFalse:
		[html tableData: [
			html attributes style: 'color: #ff0000'.
			html span: [html text: '(unspecified)']
		]]
renderInheritedAttribute: anAttribute on: html

	html text: (configuration valueForAttribute: anAttribute) printString
renderInheritedValueForAttribute: anAttribute on: html

	| inheritedValue |
	inheritedValue _ (configuration lookupValueAt: anAttribute key).
	inheritedValue
		ifNil: 
			[html attributes style: 'color: #ff0000'.
			html span: [html text: '(unspecified)']]
		ifNotNil: [html text: inheritedValue printString]
renderLinkToAncestor: aConfiguration on: html

	"html anchorWithAction: [self call: (WAConfigurationEditor new configuration: aConfiguration)] text: aConfiguration"
	html text: aConfiguration
renderOverrideForAttribute: anAttribute on: html

	html anchorWithAction: [configuration overrideAttribute: anAttribute] text: 'edit'
renderOverridenAttribute: anAttribute on: html

	anAttribute accept: self with: html
renderParent: aConfiguration on: html

	aConfiguration isMutable
		ifTrue: [html anchorWithAction: [self select: aConfiguration] text: aConfiguration name]
		ifFalse: [html text: aConfiguration name].
	html space.
	(configuration hasMutableAncestry and: [configuration ancestors includes: aConfiguration]) ifTrue:
		[html
			anchorWithAction: [configuration removeAncestor: aConfiguration] 
			text: '(remove)']
renderParentSelectorOn: html

	|selectedAncestor|
	selectedAncestor _ ValueHolder new.
	html
		selectFromList: configuration potentialAncestors
		selected: nil
		callback: [:v | selectedAncestor contents: v]
		labels: [:ea | ea name].
	html
		submitButtonWithAction: [configuration addAncestor: selectedAncestor contents]
		text: 'Add'. 
renderRevertForAttribute: anAttribute on: html

	html anchorWithAction: [configuration clearValueForAttribute: anAttribute] text: 'clear'
renderUnspecifiedAttribute: anAttribute on: html

	anAttribute accept: self with: html

rendering visitors
visitBooleanAttribute: anAttribute with: html

	html
		booleanMenuWithValue:  (configuration valueForAttribute: anAttribute)
		callback: [:v | configuration takeValue: v forAttribute: anAttribute]
		labels: #(true false)
visitColorAttribute: anAttribute with: html
 
	| group current |
	group _ html radioGroup.
	current _ configuration valueForAttribute: anAttribute.
	html
		table: [1
				to: Color indexedColors size // 20
				do: [:major | html
						tableRow: [1
								to: 20
								do: [:minor | 
									| theColor | 
									theColor _ Color indexedColors at: major - 1 * 20 + minor.
									html attributeAt: 'bgcolor' put: theColor asHTMLColor.
									html
										tableData: [html space;
												radioButtonInGroup: group
												selected: theColor = current
												callback: [:v | configuration takeValue: theColor forAttribute: anAttribute]; space]]]]]
visitListAttribute: anAttribute with: html

	html
		selectFromList: (Array with: nil), anAttribute options asArray
		selected: (configuration valueForAttribute: anAttribute)
		callback: [:v | (configuration takeValue: v forAttribute: anAttribute)]
		labels: [:ea | ea ifNil: ['None'] ifNotNil: [ea asString]]
visitNumberAttribute: anAttribute with: html

	html attributes size: 5.
	html
		textInputWithValue: (configuration valueForAttribute: anAttribute)
		callback: [:v | configuration takeValue: v asNumber forAttribute: anAttribute]
visitPasswordAttribute: anAttribute with: html

	html
		passwordInputWithCallback: [:v | configuration takeValue: v forAttribute: anAttribute]
visitStringAttribute: anAttribute with: html

	html
		textInputWithValue: (configuration valueForAttribute: anAttribute)
		callback: [:v | configuration takeValue: v forAttribute: anAttribute]

class methods:

^top


- made by Dandelion -