VE-1523: Insert template when selected and open the edit dialog

https://wikia-inc.atlassian.net/browse/VE-1523
I know what you are doing here, but it took me some time to figure out. Some comment explaining what is your intend would be appreciated.