parent
a987ffee7c
commit
5e94fb9b7b
|
@ -4,7 +4,8 @@ status.command({
|
||||||
color: "#9a5dcf"
|
color: "#9a5dcf"
|
||||||
}).param({
|
}).param({
|
||||||
name: "address",
|
name: "address",
|
||||||
type: status.types.STRING
|
type: status.types.TEXT,
|
||||||
|
placeholder: "Address"
|
||||||
});
|
});
|
||||||
|
|
||||||
var phones = [
|
var phones = [
|
||||||
|
@ -110,8 +111,9 @@ status.response({
|
||||||
color: "#5fc48d",
|
color: "#5fc48d",
|
||||||
params: [{
|
params: [{
|
||||||
name: "phone",
|
name: "phone",
|
||||||
type: status.types.PHONE_NUMBER,
|
type: status.types.PHONE,
|
||||||
suggestions: phoneSuggestions
|
suggestions: phoneSuggestions,
|
||||||
|
placeholder: "Phone number"
|
||||||
}],
|
}],
|
||||||
handler: function (params) {
|
handler: function (params) {
|
||||||
return {
|
return {
|
||||||
|
@ -127,7 +129,7 @@ status.command({
|
||||||
color: "#7099e6",
|
color: "#7099e6",
|
||||||
params: [{
|
params: [{
|
||||||
name: "query",
|
name: "query",
|
||||||
type: status.types.STRING
|
type: status.types.TEXT
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,9 @@ var status = {
|
||||||
return response.create(n, d, h);
|
return response.create(n, d, h);
|
||||||
},
|
},
|
||||||
types: {
|
types: {
|
||||||
STRING: 'string',
|
TEXT: 'text',
|
||||||
PHONE_NUMBER: 'phone-number',
|
NUMBER: 'number',
|
||||||
|
PHONE: 'phone',
|
||||||
PASSWORD: 'password'
|
PASSWORD: 'password'
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
|
|
|
@ -82,7 +82,6 @@
|
||||||
(dispatch [:initialize-protocol])
|
(dispatch [:initialize-protocol])
|
||||||
(dispatch [:load-user-phone-number])
|
(dispatch [:load-user-phone-number])
|
||||||
(dispatch [:load-contacts])
|
(dispatch [:load-contacts])
|
||||||
;; load commands from remote server (todo: uncomment)
|
|
||||||
(dispatch [:init-console-chat])
|
(dispatch [:init-console-chat])
|
||||||
(dispatch [:init-chat])
|
(dispatch [:init-chat])
|
||||||
(init-back-button-handler!)
|
(init-back-button-handler!)
|
||||||
|
|
|
@ -87,6 +87,15 @@
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(reaction (commands/get-chat-command @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
|
(register-sub :get-chat-command-content
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(reaction (commands/get-chat-command-content @db))))
|
(reaction (commands/get-chat-command-content @db))))
|
||||||
|
|
|
@ -16,20 +16,24 @@
|
||||||
(for [command staged-commands]
|
(for [command staged-commands]
|
||||||
^{:key command} [staged-command-view command])])
|
^{: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 []
|
(defview show-input []
|
||||||
[command [:get-chat-command]
|
[parameter [:get-command-parameter]
|
||||||
command? [:command?]]
|
command? [:command?]]
|
||||||
[plain-message-input-view
|
[plain-message-input-view
|
||||||
(when command?
|
(when command? (get-options parameter))])
|
||||||
(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"))))])
|
|
||||||
|
|
||||||
(defview chat-message-new []
|
(defview chat-message-new []
|
||||||
[staged-commands [:get-chat-staged-commands]]
|
[staged-commands [:get-chat-staged-commands]]
|
||||||
|
|
|
@ -34,9 +34,10 @@
|
||||||
(defn set-response-chat-command
|
(defn set-response-chat-command
|
||||||
[{:keys [current-chat-id] :as db} msg-id command-key]
|
[{:keys [current-chat-id] :as db} msg-id command-key]
|
||||||
(update-in db [:chats current-chat-id :command-input] merge
|
(update-in db [:chats current-chat-id :command-input] merge
|
||||||
{:content nil
|
{:content nil
|
||||||
:command (get-command db command-key)
|
:command (get-command db command-key)
|
||||||
:to-msg-id msg-id}))
|
:parameter-idx 0
|
||||||
|
:to-msg-id msg-id}))
|
||||||
|
|
||||||
(defn set-chat-command [db command-key]
|
(defn set-chat-command [db command-key]
|
||||||
(set-response-chat-command db nil command-key))
|
(set-response-chat-command db nil command-key))
|
||||||
|
|
Loading…
Reference in New Issue