first parameter

Former-commit-id: 013e4e79ae
This commit is contained in:
Roman Volosovskyi 2016-06-27 18:38:44 +03:00
parent a987ffee7c
commit 5e94fb9b7b
6 changed files with 37 additions and 21 deletions

View File

@ -4,7 +4,8 @@ status.command({
color: "#9a5dcf"
}).param({
name: "address",
type: status.types.STRING
type: status.types.TEXT,
placeholder: "Address"
});
var phones = [
@ -110,8 +111,9 @@ status.response({
color: "#5fc48d",
params: [{
name: "phone",
type: status.types.PHONE_NUMBER,
suggestions: phoneSuggestions
type: status.types.PHONE,
suggestions: phoneSuggestions,
placeholder: "Phone number"
}],
handler: function (params) {
return {
@ -127,7 +129,7 @@ status.command({
color: "#7099e6",
params: [{
name: "query",
type: status.types.STRING
type: status.types.TEXT
}]
});

View File

@ -92,8 +92,9 @@ var status = {
return response.create(n, d, h);
},
types: {
STRING: 'string',
PHONE_NUMBER: 'phone-number',
TEXT: 'text',
NUMBER: 'number',
PHONE: 'phone',
PASSWORD: 'password'
},
events: {

View File

@ -82,7 +82,6 @@
(dispatch [:initialize-protocol])
(dispatch [:load-user-phone-number])
(dispatch [:load-contacts])
;; load commands from remote server (todo: uncomment)
(dispatch [:init-console-chat])
(dispatch [:init-chat])
(init-back-button-handler!)

View File

@ -87,6 +87,15 @@
(fn [db _]
(reaction (commands/get-chat-command @db))))
(register-sub :get-command-parameter
(fn [db]
(let [command (subscribe [:get-chat-command])
chat-id (subscribe [:get-current-chat-id])]
(reaction
(let [path [:chats @chat-id :command-input :parameter-idx]
n (get-in @db path)]
(when n (nth (:params @command) n)))))))
(register-sub :get-chat-command-content
(fn [db _]
(reaction (commands/get-chat-command-content @db))))

View File

@ -16,20 +16,24 @@
(for [command staged-commands]
^{:key command} [staged-command-view command])])
(defn get-options [{:keys [type placeholder]}]
(let [options (case (keyword type)
:phone {:input-options {:keyboardType :phone-pad}
:validator valid-mobile-number?}
:password {:input-options {:secureTextEntry true}}
:number {:input-options {:keyboardType :numeric}}
;; todo maybe nil is fine for now :)
nil #_(throw (js/Error. "Uknown command type")))]
(println :plc placeholder)
(if placeholder
(assoc-in options [:input-options :placeholder] placeholder)
options)))
(defview show-input []
[command [:get-chat-command]
[parameter [:get-command-parameter]
command? [:command?]]
[plain-message-input-view
(when command?
(case (keyword (:name command))
:phone {:input-options {:keyboardType :phone-pad}
:validator valid-mobile-number?}
:keypair {:input-options {:secureTextEntry true}}
:confirmation-code {:input-options {:keyboardType :numeric}}
:money {:input-options {:keyboardType :numeric}}
:request {:input-options {:keyboardType :numeric}}
;; todo maybe nil is fine for now :)
nil #_(throw (js/Error. "Uknown command type"))))])
(when command? (get-options parameter))])
(defview chat-message-new []
[staged-commands [:get-chat-staged-commands]]

View File

@ -34,9 +34,10 @@
(defn set-response-chat-command
[{:keys [current-chat-id] :as db} msg-id command-key]
(update-in db [:chats current-chat-id :command-input] merge
{:content nil
:command (get-command db command-key)
:to-msg-id msg-id}))
{:content nil
:command (get-command db command-key)
:parameter-idx 0
:to-msg-id msg-id}))
(defn set-chat-command [db command-key]
(set-response-chat-command db nil command-key))