|
8 | 8 | package org.roda.wui.client.common.dialogs; |
9 | 9 |
|
10 | 10 | import com.google.gwt.i18n.client.DateTimeFormat; |
11 | | -import com.google.gwt.user.client.ui.SimplePanel; |
12 | 11 | import com.google.gwt.user.client.ui.TextBox; |
13 | 12 | import com.google.gwt.user.datepicker.client.DateBox; |
14 | 13 | import org.roda.core.data.v2.accessKey.AccessKey; |
@@ -103,66 +102,27 @@ public void onClick(ClickEvent clickEvent) { |
103 | 102 | dialogBox.show(); |
104 | 103 | } |
105 | 104 |
|
106 | | - public static void showCreateAccessTokenModal(final AsyncCallback<String> callback) { |
107 | | - final DialogBox dialogBox = new DialogBox(false, true); |
108 | | - dialogBox.setText("Create access token"); |
109 | | - |
110 | | - final FlowPanel layout = new FlowPanel(); |
111 | | - |
112 | | - final Label messageLabel = new Label("test"); |
113 | | - layout.add(messageLabel); |
114 | | - messageLabel.addStyleName("wui-dialog-message"); |
115 | | - |
116 | | - final Button cancelButton = new Button(messages.cancelButton()); |
117 | | - final Button confirmButton = new Button(messages.saveButton()); |
118 | | - |
119 | | - layout.add(cancelButton); |
120 | | - layout.add(confirmButton); |
121 | | - |
122 | | - dialogBox.setWidget(layout); |
123 | | - |
124 | | - dialogBox.setGlassEnabled(true); |
125 | | - dialogBox.setAnimationEnabled(false); |
126 | | - |
127 | | - cancelButton.addClickHandler(new ClickHandler() { |
128 | | - |
129 | | - @Override |
130 | | - public void onClick(ClickEvent event) { |
131 | | - dialogBox.hide(); |
132 | | - callback.onFailure(null); |
133 | | - } |
134 | | - }); |
135 | | - |
136 | | - dialogBox.addStyleName("wui-dialog-prompt"); |
137 | | - layout.addStyleName("wui-dialog-layout"); |
138 | | - cancelButton.addStyleName("btn btn-link"); |
139 | | - confirmButton.addStyleName("pull-right btn btn-play"); |
140 | | - |
141 | | - dialogBox.center(); |
142 | | - dialogBox.show(); |
143 | | - } |
144 | | - |
145 | | - public static void showRegenerateAccessKeyDialog(String title, String tokenName, boolean create, |
146 | | - final AsyncCallback<CreateAccessKeyRequest> callback) { |
| 105 | + public static void createAccessKeyDialog(String title, String tokenName, boolean create, |
| 106 | + final AsyncCallback<CreateAccessKeyRequest> callback) { |
147 | 107 | final DialogBox dialogBox = new DialogBox(false, true); |
148 | 108 | final Button cancelButton = new Button(messages.cancelButton()); |
149 | 109 | final Button confirmButton = new Button(messages.confirmButton()); |
150 | 110 | final FlowPanel layout = new FlowPanel(); |
151 | 111 | final FlowPanel header = new FlowPanel(); |
152 | 112 | final FlowPanel footer = new FlowPanel(); |
153 | 113 |
|
154 | | - final Label tokenNameLabel = new Label("Name"); |
| 114 | + final Label tokenNameLabel = new Label(messages.accessKeyNameLabel()); |
155 | 115 | final TextBox tokenNameTextBox = new TextBox(); |
156 | | - final Label tokenNameTextBoxErrorLabel = new Label("Mandatory field"); |
| 116 | + final Label tokenNameTextBoxErrorLabel = new Label(messages.mandatoryField()); |
157 | 117 |
|
158 | 118 | if (!create) { |
159 | 119 | tokenNameTextBox.setText(tokenName); |
160 | 120 | tokenNameTextBox.setEnabled(false); |
161 | 121 | } |
162 | 122 |
|
163 | | - final Label expirationDateLabel = new Label("Expiration date"); |
| 123 | + final Label expirationDateLabel = new Label(messages.accessKeyExpirationDateLabel()); |
164 | 124 | final DateBox expirationDateBox = new DateBox(); |
165 | | - final Label expirationDateErrorLabel = new Label("Invalid Date"); |
| 125 | + final Label expirationDateErrorLabel = new Label(); |
166 | 126 |
|
167 | 127 | tokenNameTextBoxErrorLabel.addStyleName("form-label-error"); |
168 | 128 | tokenNameTextBoxErrorLabel.setVisible(false); |
@@ -204,8 +164,13 @@ public void onClick(ClickEvent clickEvent) { |
204 | 164 | } |
205 | 165 |
|
206 | 166 | Date selectedDate = expirationDateBox.getValue(); |
207 | | - if (selectedDate == null || selectedDate.before(new Date())) { |
| 167 | + if (selectedDate == null) { |
| 168 | + expirationDateErrorLabel.setVisible(true); |
| 169 | + expirationDateErrorLabel.setText(messages.mandatoryField()); |
| 170 | + errors = true; |
| 171 | + } else if (selectedDate.before(new Date())) { |
208 | 172 | expirationDateErrorLabel.setVisible(true); |
| 173 | + expirationDateErrorLabel.setText(messages.accessKeyExpirationDateInThePast()); |
209 | 174 | errors = true; |
210 | 175 | } else { |
211 | 176 | expirationDateErrorLabel.setVisible(false); |
|
0 commit comments