Merge branch 'feature/command-parameters' into feature/command-suggestions-animation
Former-commit-id: 904decc76a
This commit is contained in:
commit
e90ecc5ce9
|
@ -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])])
|
||||||
|
|
||||||
(defview show-input []
|
(defn get-options [{:keys [type placeholder]}]
|
||||||
[command [:get-chat-command]
|
(let [options (case (keyword type)
|
||||||
command? [:command?]]
|
|
||||||
[plain-message-input-view
|
|
||||||
(when command?
|
|
||||||
(case (keyword (:name command))
|
|
||||||
:phone {:input-options {:keyboardType :phone-pad}
|
:phone {:input-options {:keyboardType :phone-pad}
|
||||||
:validator valid-mobile-number?}
|
:validator valid-mobile-number?}
|
||||||
:keypair {:input-options {:secureTextEntry true}}
|
:password {:input-options {:secureTextEntry true}}
|
||||||
:confirmation-code {:input-options {:keyboardType :numeric}}
|
:number {:input-options {:keyboardType :numeric}}
|
||||||
:money {:input-options {:keyboardType :numeric}}
|
|
||||||
:request {:input-options {:keyboardType :numeric}}
|
|
||||||
;; todo maybe nil is fine for now :)
|
;; todo maybe nil is fine for now :)
|
||||||
nil #_(throw (js/Error. "Uknown command type"))))])
|
nil #_(throw (js/Error. "Uknown command type")))]
|
||||||
|
(println :plc placeholder)
|
||||||
|
(if placeholder
|
||||||
|
(assoc-in options [:input-options :placeholder] placeholder)
|
||||||
|
options)))
|
||||||
|
|
||||||
|
(defview show-input []
|
||||||
|
[parameter [:get-command-parameter]
|
||||||
|
command? [:command?]]
|
||||||
|
[plain-message-input-view
|
||||||
|
(when command? (get-options parameter))])
|
||||||
|
|
||||||
(defview chat-message-new []
|
(defview chat-message-new []
|
||||||
[staged-commands [:get-chat-staged-commands]]
|
[staged-commands [:get-chat-staged-commands]]
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
(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)
|
||||||
|
:parameter-idx 0
|
||||||
:to-msg-id msg-id}))
|
:to-msg-id msg-id}))
|
||||||
|
|
||||||
(defn set-chat-command [db command-key]
|
(defn set-chat-command [db command-key]
|
||||||
|
|
Loading…
Reference in New Issue