Skip to content

Commit 2fba668

Browse files
authored
Merge pull request #1290 from Julesboul/fix/protocolChoice
Fix bug when choosing a protocol name
2 parents 9804c77 + 673a0ab commit 2fba668

File tree

2 files changed

+8
-39
lines changed

2 files changed

+8
-39
lines changed

src/NewTools-Core-Tests/StProtocolNameChooserPresenterTest.class.st

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ StProtocolNameChooserPresenterTest >> setUp [
1818
presenter := StProtocolNameChooserPresenter new
1919
]
2020

21-
{ #category : 'running' }
22-
StProtocolNameChooserPresenterTest >> testAddButtonIsDiabledWhenTextFieldIsEmpty [
23-
24-
self assertEmpty: presenter protocolName.
25-
self deny: presenter newProtocolButton isEnabled.
26-
27-
presenter protocolName: 'ANewProtocol'.
28-
self assert: presenter newProtocolButton isEnabled
29-
]
30-
3121
{ #category : 'tests' }
3222
StProtocolNameChooserPresenterTest >> testCreatingProtocolThatDoesntExists [
3323
"When creating a protocol that doesn't exist beforehand, it should create it correctly with the same name as written."
@@ -44,16 +34,15 @@ StProtocolNameChooserPresenterTest >> testCreatingProtocolThatDoesntExists [
4434

4535
{ #category : 'tests' }
4636
StProtocolNameChooserPresenterTest >> testCreatingProtocolThatExists [
47-
"When creating a protocol that does exist beforehand, it should create the name of the suggested protocol instead of the name written."
48-
| protocolName |
37+
"When creating a new protocol, it should create the name written."
4938

50-
protocolName := 'acc' .
39+
| protocolName |
40+
protocolName := 'acc'.
5141
presenter concernedClass: self class.
52-
42+
5343
presenter protocolName: protocolName.
5444
presenter doAcceptFromTextInput.
55-
self assert: presenter selectedProtocolName equals: 'accessing'
56-
45+
self assert: presenter selectedProtocolName equals: 'acc'
5746
]
5847

5948
{ #category : 'tests' }

src/NewTools-Core/StProtocolNameChooserPresenter.class.st

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Class {
1818
'suggestionList',
1919
'protocolNameField',
2020
'concernedClass',
21-
'newProtocolButton',
2221
'selectedProtocolName'
2322
],
2423
#category : 'NewTools-Core-Calypso',
@@ -76,9 +75,7 @@ StProtocolNameChooserPresenter >> connectPresenters [
7675
protocolNameField whenTextChangedDo: [ self updatePresenter ].
7776
protocolNameField whenSubmitDo: [ :aString | self doAcceptFromTextInput ].
7877

79-
suggestionList whenActivatedDo: [ self doAcceptFromList ].
80-
81-
newProtocolButton action: [ self doAcceptFromTextInput ]
78+
suggestionList whenActivatedDo: [ self doAcceptFromList ]
8279
]
8380

8481
{ #category : 'layout' }
@@ -90,7 +87,6 @@ StProtocolNameChooserPresenter >> defaultLayout [
9087
add: (SpBoxLayout newLeftToRight
9188
spacing: 3;
9289
add: protocolNameField expand: true;
93-
add: newProtocolButton expand: false;
9490
yourself)
9591
expand: false;
9692
yourself
@@ -106,8 +102,7 @@ StProtocolNameChooserPresenter >> doAcceptFromList [
106102
{ #category : 'private - actions' }
107103
StProtocolNameChooserPresenter >> doAcceptFromTextInput [
108104

109-
selectedProtocolName := suggestionList selectedItem
110-
ifNil: [ protocolNameField text. ].
105+
selectedProtocolName := protocolNameField text.
111106
self withWindowDo: [ :w | w beOk; close ]
112107
]
113108

@@ -128,12 +123,6 @@ StProtocolNameChooserPresenter >> initializePresenters [
128123
protocolNameField := self newTextInput.
129124
protocolNameField placeholder: 'Protocol name (e.g. accessing)'.
130125

131-
newProtocolButton := self newButton.
132-
newProtocolButton
133-
addStyle: 'small';
134-
icon: (self iconNamed: #add);
135-
help: 'Create a new protocol with the content of the input field if this protocol is not in the list'.
136-
137126
self initializeProtocolNameField
138127
]
139128

@@ -166,12 +155,6 @@ StProtocolNameChooserPresenter >> initializeWindow: aWindowPresenter [
166155
aWindowPresenter whenOpenedDo: [ protocolNameField takeKeyboardFocus ]
167156
]
168157

169-
{ #category : 'private - accessing' }
170-
StProtocolNameChooserPresenter >> newProtocolButton [
171-
172-
^ newProtocolButton
173-
]
174-
175158
{ #category : 'private - accessing' }
176159
StProtocolNameChooserPresenter >> protocolName [
177160
^ protocolNameField text asSymbol
@@ -249,9 +232,6 @@ StProtocolNameChooserPresenter >> selectedProtocolName [
249232
{ #category : 'initialization' }
250233
StProtocolNameChooserPresenter >> updatePresenter [
251234

252-
newProtocolButton enabled: self protocolName isNotEmpty.
253-
254235
suggestionList
255-
items: self protocolsToSuggest;
256-
selectFirst
236+
items: self protocolsToSuggest
257237
]

0 commit comments

Comments
 (0)