mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-07 16:48:02 +08:00
365fe400f7
Summary: tests on the schemas build input elements form builder pulls data grouping by row salesforce object store salesforce api logic successfully pulling salesforce objects into db object store saving to db refactoring tokenizing text field full documented tokenizing text field with specs linking in object picker component converting generated form to a controlled input form change handlers for controlled inputs Salesforce object creator store new way of opening windows removed atom.state.mode create new salesforce object creator in new window form creator loading in popup with generated form generated form renders select and multiselcet and textarea add checkbox creating related objects windnows know when others close remove debugger statements form submission converting data for salesforce posting hot window loading new hot window registration hot loading windows actions for listening to salesforce objects created generated form errors error handling for salesforce object creator rename saleforce object form store display errors to form submitting state passed through properly posts objects to Salesforce change name to salesforce object form add deep clone use formItemEach styling for Salesforce form creator salesforce required fields come back and populate form generated form loads related objects into fields remove console logs and fix sales schema adapter test fix task queue and formbuilder specs fix action bridge spec fix tokenizing text field spec fix draft store and tokenizing proptypes fix linter issues fix tokenizing text field bug rename to refresh window props remove console.log Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://review.inboxapp.com/D1425
103 lines
3.2 KiB
CoffeeScript
103 lines
3.2 KiB
CoffeeScript
_ = require 'underscore-plus'
|
|
React = require 'react'
|
|
|
|
{NamespaceStore,
|
|
DatabaseStore,
|
|
Message,
|
|
ComponentRegistry,
|
|
WorkspaceStore} = require('inbox-exports')
|
|
NewComposeButton = require('./new-compose-button')
|
|
ComposerView = require('./composer-view')
|
|
|
|
module.exports =
|
|
item: null # The DOM item the main React component renders into
|
|
|
|
activate: (@state={}) ->
|
|
|
|
atom.registerHotWindow
|
|
windowType: "composer"
|
|
replenishNum: 2
|
|
|
|
# Register our composer as the app-wide Composer
|
|
ComponentRegistry.register
|
|
name: 'Composer'
|
|
view: ComposerView
|
|
|
|
if atom.isMainWindow()
|
|
@_activateComposeButton()
|
|
else
|
|
windowProps = atom.getLoadSettings().windowProps ? {}
|
|
@refreshWindowProps(windowProps)
|
|
|
|
refreshWindowProps: (windowProps) ->
|
|
return unless windowProps.createNew
|
|
|
|
if @item? then return # Activate once
|
|
@item = document.createElement("div")
|
|
@item.setAttribute("id", "composer-full-window")
|
|
@item.setAttribute("class", "composer-full-window")
|
|
document.body.appendChild(@item)
|
|
|
|
@_prepareDraft(windowProps).then (draftLocalId) =>
|
|
React.render(
|
|
<ComposerView mode="fullwindow" localId={draftLocalId} />, @item
|
|
)
|
|
.catch (error) ->
|
|
console.error(error.stack)
|
|
|
|
deactivate: ->
|
|
if atom.isMainWindow()
|
|
React.unmountComponentAtNode(@new_compose_button)
|
|
@new_compose_button.remove()
|
|
@new_compose_button = null
|
|
else
|
|
React.unmountComponentAtNode(@item)
|
|
@item.remove()
|
|
@item = null
|
|
|
|
serialize: -> @state
|
|
|
|
# This logic used to be in the DraftStore (which is where it should be). It
|
|
# got moved here becaues of an obscure atom-shell/Chrome bug whereby database
|
|
# requests firing right before the new-window loaded would cause the
|
|
# new-window to load with about:blank instead of its contents. By moving the
|
|
# DB logic here, we can get around this.
|
|
_prepareDraft: ({draftLocalId, draftInitialJSON}={}) ->
|
|
# The NamespaceStore isn't set yet in the new window, populate it first.
|
|
NamespaceStore.populateItems().then ->
|
|
new Promise (resolve, reject) ->
|
|
if draftLocalId?
|
|
resolve(draftLocalId)
|
|
else
|
|
# Create a new draft
|
|
draft = new Message
|
|
body: ""
|
|
from: [NamespaceStore.current().me()]
|
|
date: (new Date)
|
|
draft: true
|
|
pristine: true
|
|
namespaceId: NamespaceStore.current().id
|
|
# If initial JSON was provided, apply it to the new model.
|
|
# This is used to apply the values in mailto: links to new drafts
|
|
if draftInitialJSON
|
|
draft.fromJSON(draftInitialJSON)
|
|
|
|
DatabaseStore.persistModel(draft).then ->
|
|
DatabaseStore.localIdForModel(draft).then(resolve).catch(reject)
|
|
.catch(reject)
|
|
|
|
_activateComposeButton: ->
|
|
ComponentRegistry.register
|
|
view: NewComposeButton
|
|
name: 'NewComposeButton'
|
|
location: WorkspaceStore.Location.RootSidebar.Toolbar
|
|
|
|
_showInitialErrorDialog: (msg) ->
|
|
remote = require('remote')
|
|
dialog = remote.require('dialog')
|
|
dialog.showMessageBox remote.getCurrentWindow(), {
|
|
type: 'warning'
|
|
buttons: ['Okay'],
|
|
message: "Error"
|
|
detail: msg
|
|
}
|